我無法弄清楚如何從父元素中刪除類,基本上我有一個<audio>
標記(從現在開始被稱爲this
),這是在class="playing"
div中的內容我該如何刪除此類?使用jQuery從父元素中移除類?
想這一點,但比了解,它將從音頻元素刪除類不是它的父格:
this.removeClass("playing");
我無法弄清楚如何從父元素中刪除類,基本上我有一個<audio>
標記(從現在開始被稱爲this
),這是在class="playing"
div中的內容我該如何刪除此類?使用jQuery從父元素中移除類?
想這一點,但比了解,它將從音頻元素刪除類不是它的父格:
this.removeClass("playing");
this.parent().removeClass("playing");
$(this).closest('div').removeClass("playing")
或
$(this).closest('div.playing').removeClass('playing')
this.closest('div[class=playing]').removeClass("playing");
的jsfiddle Demo
<div class="bold">
<p id="p1" class="blue under">Hello</p>
</div>
<div class="bold">
<p id="p2" class="blue under highlight">and</p>
</div>
<p class="blue under">then</p>
<p class="blue under">Goodbye</p>
$("#p1").parent().removeClass("bold");
嚴重的是,這是關於基本,你可以得到。你爲什麼不放棄的努力只是一點點,遊覽【jQuery的文檔(http://api.jquery.com/),鍵入「父」,看看會發生什麼吧。這對你來說真的太難了嗎? – 2013-04-16 21:30:48