JQuery 可见选择器和 prev()
我试图确定具有特定类的哪个元素是可见的。然后找到它的前一个元素并滑到它上面。我尝试了这个,但它不正确。
if($('#sidepanel1').is(':visible')) {
}
else {
var prevpanel = $('.sidewrapper').is(':visible').prev().attr('id'); alert(prevpanel);
$('.sidewrapper').hide("slide", { direction: "right" }, 300); $(prevpanel).show("slide", { direction: "left" }, 300);
}
}
这与我使用 :visible 有关,我认为这是错误的。有什么想法吗?
奇妙
I am trying to determine which element with a particular class is visible. Then find its immediate previous element and slide over to it. I tried this but it is not correct.
if($('#sidepanel1').is(':visible')) {
}
else {
var prevpanel = $('.sidewrapper').is(':visible').prev().attr('id'); alert(prevpanel);
$('.sidewrapper').hide("slide", { direction: "right" }, 300); $(prevpanel).show("slide", { direction: "left" }, 300);
}
}
Its something to do with my use of :visible that I think is wrong. Any ideas?
Marvellous
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
更改
为
.is()
返回bool
change
to
the
.is()
returnsbool
根据文档,
is()
只会返回一个布尔值那种情况。它不会返回 jQuery 对象的另一个实例,因此您的链已损坏。According to the docs,
is()
would only return a boolean value in that case. It doesn't return another instance of the jQuery object, so your chain is broken.