For loop for the all rows in the html table

Home Forums Web Development HTML, JavaScript and CSS For loop for the all rows in the html table

Tagged: 

This topic contains 0 replies, has 2 voices, and was last updated by  Hirendra Sisodiya 4 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4930

    Pavan
    Moderator

    Can I use the for loop instead of for each for the all rows in the html table?

    Let’s suppose my table is:

    <table id="tblLoop">
      <tbody>
        <tr>...</tr>
        <tr>...</tr>
      </tbody>
    </table>
    #4934

    You can use the following code:

    var rows = $(“#tblLoop”)[0].find(‘tr’);
    if ($(rows).length != 0) {
    for (var j = 0; j < $(rows).length; j++) { // do somthing } }

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.