如何将相邻的选择符"+“与$(this)一起使用。
我需要一个帮助来处理带有//this work work的注释行:
$(".ExpandCollapse").click(function () {
if ($(this).nextUntil('.Collapsable').is(':visible'))
{
//this doesnt work
$(this + ".Collapsable").hide();
}
else
{
//this doesnt work
$(this + ".Collapsable").show();
}
});能帮我一把吗?
在此之前非常感谢。
诚挚的问候。
何塞
发布于 2010-08-05 17:38:20
使用next()
$(this).next(".Collapsable").hide();或者简单地说:
$(this).next().hide();发布于 2010-08-05 17:41:21
你也可以减少使用两个语句来隐藏和显示:
$(this).next().toggle();发布于 2010-08-05 17:42:32
this是对调用的DOM element的引用。您不能将string与此连接起来。
因此,您可以直接使用this对其执行操作
$(this).hide();或者,您可以从那里遍历DOM
$(this).next().hide();
$(this).prev().hide();
$(this).closest('.Collapsable').hide();
// another 200 methodshttps://stackoverflow.com/questions/3413435
复制相似问题