JQuery each loop problem

Posted by bhefny on Stack Overflow See other posts from Stack Overflow or by bhefny
Published on 2010-06-02T15:36:05Z Indexed on 2010/06/02 15:54 UTC
Read the original article Hit count: 154

Filed under:
|
|

Hello,

I have the following code

  <div>
 <a href="#" class="clickMe">test</a>
 <ul>
     <li class="action_li">1</li>
     <li class="action_li">2</li>
 </ul></div> <div>
 <a href="#" class="clickMe">test</a>
 <ul>
     <li class="action_li">3</li>
     <li class="action_li">4</li>
 </ul>

and I want to loop on all the <li> that are enclosed with the same <div> as the clicked <a>

$("a.clickMe").live("click", function(eve){
   eve.preventDefault();
   $('.action_li').each(function(index) {
      console.debug(this);
   }); 
});

but of course this will get me all the 4 <li> not the two enclosed so I want to have something that starts with $(this) and ends with .each()

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery