javascript - Get element node count with jquery -
i don't know if can explain right...
i have table this:
<table>     <tr>         <td class="mytd">aaa</td>         <td class="mytd">bbb</td>         <td class="mytd">ccc</td>         <td class="mytd">ddd</td>         <td class="mytd">eee</td>     </tr> </table>   some jquery this:
$('.mytd').on('click', function(e){     //... here ...// });   when click on td want node count of clicked td.
e.g. if click on ccc want alert 3
is possible in way or have explizit add id ?
$('.mytd').on('click', function(){      alert( $(this).index() );  });  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <table>      <tr>          <td class="mytd">aaa</td>          <td class="mytd">bbb</td>          <td class="mytd">ccc</td>          <td class="mytd">ddd</td>          <td class="mytd">eee</td>      </tr>  </table>  
Comments
Post a Comment