youv youv - 1 year ago 92
Javascript Question

Getting table tr id undefined

Am getting the return value of a table tr:last id undefined

<table id="tableid">
<tr id="1"><td>1</td>
<tr id="2"><td>2</td>

$("#tableid tbody tr:last").attr('id');

Please help,

Answer Source

your code is working fine.check below

   <script src="">

var lastid=$("#tableid tbody tr:last").attr('id');  

 <table id="tableid" >

 <tr id="trid1"></tr> 
   <tr id="trid2"> </tr>
    <tr id="trid3"></tr>
 </table >
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download