我有這樣的設置在我的HTML運行到元素最接近元素點擊jQuery的
<section class="grp">
<ul class="normal">
<li>Normal Thing <button class="toggle-advanced">toggle advanced</button></li>
</ul>
<ul class="advanced">
<li>This is Advanced</li>
</ul>
</section>
<h1>Another Thing</h1>
<section class="grp">
<ul class="normal">
<li>Normal Thing <button class="toggle-advanced">toggle advanced</button></li>
</ul>
<ul class="advanced">
<li>This is Advanced</li>
</ul>
</section>
我怎樣才能切換「高級」 ul
如果我點擊在ul.normal
按鈕?
我試過像這樣的CoffeeScript
$('.normal').on 'click', '.toggle-advanced', (e) ->
$(@).closest('.grp').siblings('.advanced').slideToggle();
我用了第三個。 –
很酷...很高興它幫助..快樂編碼.. – bipen