私はすでにこの脅威を発見しました: How to toggle only the *next* .class or div (not the rest)
しかし、切り替えたいクラスがクリック要素の子要素ではない場合、私がしなければならないことは次のとおりです。
<span onclick="$(this).next('.showme').slideToggle();">Klick to show first Showme-Class</span>
<div class="showme">You've clicked the first span-element</div>
<span onclick="$(this).next('.showme').slideToggle();">Klick to show second Showme-Class</span>
<div class="showme">You've clicked the second span-element</div>
<span onclick="$(this).next('.showme').slideToggle();">Klick to show third Showme-Class</span>
<div class="showme">You've clicked the third span-element</div>
より具体的に:この例では...
<div class="myclickclass">
<span onclick="this().next('.showme').slideToggle(100);">Click me</span>
<div class="showme">You've clicked</div>
</div>
クラス「showme」は、クラス「myclickclass」の一部(内部)です.... jQueryは私にとってはうまくいきます。
<div class="myclickclass">
<span onclick="this().next('.showme').slideToggle(100);">Click me</span>
</div>
<div class="showme">You've clicked</div>
この例では、クラス「showme」は私のクラス「myclickclass」の一部ではありません。jQueryは私にはうまくいきません。