開始時,除第一個外,所有.show-this
部分都是隱藏的。在JQuery中選擇下一個不匹配的元素
然後,當單擊.btn-next
時,前述.show-this
部應觸發類.visible
HTML
<section class="show-this">
...
</section>
<button class="btn-next">Next</button>
<section class="show-this">
...
</section>
<button class="btn-next">Next</button>
<section class="show-this">
...
</section>
JQuery的
$('.btn-next').click(function(){
$(this).closest('.show-this').toggleClass('visible'); // doesn't work
$(this).prop('disabled', true);
});
有':在[CSS規範] first'選擇(https://www.w3.org/wiki/CSS/Selectors#Pseudo-classes)? – Alexander
':first'不是CSS規範的一部分,它的jQuery擴展! –
謝謝,我會知道的! – Alexander