javascript - jQuery toggle on multiple divs with same class -
i trying jquery toggle , running on site.
so far code is:
<script> $(document).ready(function(){ $(".flip").click(function(){ $(".flippanel").toggle(); }); }); </script>
i in html have:
<p class="flip">flip it!</p> <p class="flippanel">this paragraph little content.</p> <p class="flippanel">this little paragraph.</p> <p class="flip 2">flip it!</p> <p class="flippanel 2 ">this paragraph little content.</p> <p class="flippanel 2">this little paragraph.</p>
how go getting toggle 2 panels independently? right now, each panel toggles @ same time.
select next 2 p .flippanel
of 1 click each time.
nextall
select next siblings
slice(0, 2)
narrows first two
try:
$(".flip").click(function(){ $(this).nextall(".flippanel").slice(0, 2).toggle(); });
demo
javascript jquery html css toggle
No comments:
Post a Comment