Moti Mashiah
asked on
javascript\jquery
Hi Guys,
I am trying to loop through my table with javascript:
Here is my dom:
Note: this table is getting 5 rows:
Now this is what I'm doing in my javascript code:
I'm trying to loop through the table and get number of rows. The issue is that it loops once and finish the loop.
Usually I do these things with jquery which is very easy, but I would like to do it with javascript this time.
Please, any help.
I am trying to loop through my table with javascript:
Here is my dom:
Note: this table is getting 5 rows:
<table class="table table-bordered" id="tableid">
<thead>
<tr>
<th>Itemlookup</th>
<th>Description</th>
<th>Option</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
<input type="text" value="@item.ItemLookupCode" id="itmlookupid" />
</td>
<td>
<input type="text" value="@item.Description" id="descid" />
</td>
<td>
<a id="editme" onclick="getRows()">edit </a>
<input type="hidden" value="@item.ID" id="iddata" />
</td>
</tr>
}
</tbody>
</table>
Now this is what I'm doing in my javascript code:
function getRows() {
var table = document.getElementById("tableid").tBodies[0]
debugger;
for (var i = 0; i < table.rows; i++) {
debugger;
var rownum = i;
}
}
I'm trying to loop through the table and get number of rows. The issue is that it loops once and finish the loop.
Usually I do these things with jquery which is very easy, but I would like to do it with javascript this time.
Please, any help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER