[英]Jquery next adjacent selector with $(this)
我怎么能用$(this)使用相鄰的選擇器“+”。
我需要幫助注釋行//這不起作用:
$(".ExpandCollapse").click(function () {
if ($(this).nextUntil('.Collapsable').is(':visible'))
{
//this doesnt work
$(this + ".Collapsable").hide();
}
else
{
//this doesnt work
$(this + ".Collapsable").show();
}
});
你能幫我個忙嗎?
非常感謝提前。
最好的祝福。
何塞
您還可以減少隱藏和顯示的兩個語句:
$(this).next().toggle();
this
是對DOM element
調用DOM element
的引用。 你不能將string
到那個。
所以你要么直接用this
來對它采取行動
$(this).hide();
或者你可以從那里走過DOM
$(this).next().hide();
$(this).prev().hide();
$(this).closest('.Collapsable').hide();
// another 200 methods
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.