jQuery与此的多个选择器 [英] Jquery multiple selectors with this
本文介绍了jQuery与此的多个选择器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索了,但是找不到如何执行此操作.我正在尝试隐藏和显示this
中带有comment-modbox
的元素:
I've searched but can't find how to do this. I'm trying to make the elements with comment-modbox
inside this
hide and show:
$('.comment-wrapper').each(function (index) {
$(this, '.comment-modbox').mouseover(function () {
$('.comment-modbox').show();
});
$(this, '.comment-modbox').mouseout(function () {
$('.comment-modbox').hide();
});
});
此代码只是隐藏并显示所有comment-modbox
,无论它们是否包含在this
中.
This code just hides and shows all comment-modbox
regardless as to if they are contained within this
.
感谢您的帮助!
$('.comment-wrapper').each(function (index) {
$(this).mouseover(function () {
$('.comment-modbox', this).show();
});
$(this).mouseout(function () {
$('.comment-modbox', this).hide();
});
});
推荐答案
试试这个( jQuery("selector",上下文)... )
$('.comment-wrapper').each(function (index) {
$('.comment-modbox', this).mouseover(function () {
$(this).show();
});
$('.comment-modbox', this).mouseout(function () {
$(this).hide();
});
});
第二选择:
$('.comment-wrapper').each(function (index) {
var wrapper = this;
$('.comment-modbox', wrapper)
.mouseover(function () {
$(this).show();
})
.mouseout(function () {
$(this).hide();
});
});
这篇关于jQuery与此的多个选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文