javascript - an easy way to get all the table rows from a table without using a loop -
is there easy way table rows table without using loop.
i thought work alerts first row.
$(document).ready(function () { var o = $('#maintable').find('tr'); //var o = $('#maintable tr'); alert(o.html()); //alerts <th>month</th><th>savings</th> }); <table id ="maintable" border="1"> <caption>monthly savings</caption> <tr> <th>month</th> <th>savings</th> </tr> <tr> <td>january</td> <td>$100</td> </tr> <tr> <td>february</td> <td>$50</td> </tr> <tr> <td>march</td> <td>$50</td> </tr> <tr> <td>a</td> <td>$50</td> </tr> <tr> <td>m</td> <td>$50</td> </tr> <tr> <td>j</td> <td>$50</td> </tr> <tr> <td>july</td> <td>$50</td> </tr> <tr> <td>aug</td> <td>$50</td> </tr> <tr> <td>sep</td> <td>$50</td> </tr> </table>
what about:
// tr (excluding caption) var o = $('table#maintable').children().slice(1);
Comments
Post a Comment