html - How to trigger neighbour element to "this" object in jquery -


i have 1 button - <a> link , list - ul. need show/hide list when click on button. here code:

<div class="wide-tile" id="tile-1">     <div class="size-set">         <a href="#" class="toggle-btn"> > </a>         <ul class="size-list">             <li>1x1</li>             <li>1x2</li>             <li>2x1</li>             <li>2x2</li>         </ul>     </div>     <a href="details.html" class="wide-tile-link">         <span class="title">about us</span>     </a> </div> 

the problem is: have many tiles , each of has same "set-size" class div. when press on link need toggle ul list. far i've done on jquery

$(".size-set").click(function(){     $(".toggle-btn",this).click(function(){         $(".size-list",this).toggle("slow","swing");     }); }); 

it doesn't work, maybe because $(".size-list",this) construction used parent , child class. need same dom level access.

you need bind $(".toggle-btn").click separately , use $.fn.next sibling .size-list toggle. in case don't need click event on .size-set anymore:

$(".toggle-btn").click(function() {     $(this).next(".size-list").toggle("slow", "swing"); }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -