最初は、.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);
});
このplunkrをチェックアウト 'あります:[CSS仕様](https://www.w3.org/wiki/CSS/Selectors#Pseudo-classes)でfirst'セレクタ! – Alexander
':first'はCSS仕様の一部ではなく、そのjQuery拡張機能です! –
ありがとう、私は知っている! – Alexander