jquery - How to toggle all .class elements in the parent container -
i have parent container lot of elements. need toggle of them clicking button located in container, here's example
<div class="my-container"> <a href="/">home</a> <div class="toggle-me visible">1</div> <div class="toggle-me hidden">2</div> <div> <strong>press me</strong> <button class="i-am-toggle">toggle</button> </div> </div>
can please advice how toggle elements class in same button's container jquery?
something should started:
$('.i-am-toggle').click(function(){ $(this).closest('.my-container').find('.toggle-me').toggle(); });
assumes have multiple "my-container" , want toggle instances of visible
, hidden
class within specific container
Comments
Post a Comment