html - Alert the count of <li>s in an adjacent <div> to a button being clicked -
this first post website has been useful here goes... oh , im beginner ;-)
- i have button (a div class) , div inside element side side.
 - inside second div have ul , number of li's dynamically change.
 - when button clicked, need count of li's in div next button only
 - the various alerts i've used wrong , return count of li's inside 'hidden-row-content' not adjacent 'hidden-row-content' div returns 4 instead of 2 :-(
 
html code:
<td>     <div class="show-hidden-row"><!-- --></div>     <div class="hidden-row-content">         <ul>             <li>item</li>             <li>item</li>         </ul>     </div>     <em>persons name</em> </td> <td>     <div class="show-hidden-row"><!-- --></div>     <div class="hidden-row-content">         <ul>             <li>item</li>             <li>item</li>         </ul>     </div>     <em>persons name</em> </td>   jquery code:
non of these right 1 close enough spot problem
$(".show-hidden-row").click (function() {      window.alert($(this,".hidden-row-content").children("ul").length);     window.alert($(this).find('.hidden-row-content ul li').length);     window.alert($('.hidden-row-content ul li').length);     window.alert($(this).next('.hidden-row-content').length);    } );      
this finds next <div>, , searches <li>s:
$(this).next('.hidden-row-content').find('li').length   working example: http://jsbin.com/orudu
Comments
Post a Comment