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

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -