首頁  >  文章  >  web前端  >  js實作遍歷含有input的table實例_javascript技巧

js實作遍歷含有input的table實例_javascript技巧

WBOY
WBOY原創
2016-05-16 15:27:241477瀏覽

本文實例講述了js實作遍歷含有input的table。分享給大家參考,具體如下:

table 如下:

<table id="groupTable" class="tblist_black">
<%
 DataTable firstGroupTable = ViewState["firstGroupTable"] as DataTable;
 if (firstGroupTable != null)
 {
 for (int i = 0; i < firstGroupTable.Rows.Count; i )
 {
 %>
  <tr>
  <td><div style="width:40px;"><span>一级</span></div></td>
  <td><div style="width:40px;"><span> </span></div></td>
  <td><div style="width:180px;"><span><input type="text" value="<%=firstGroupTable.Rows[i]["GroupName"]%>" /></span></div></td>
  <td style="display:none"><div style="width:80px;"><span><%=firstGroupTable.Rows[i]["FirstNodeID"]%></span></div></td>
  <td style="display:none"><div style="width:80px;"><span> </span></div></td>
  <td><div style="width:60px;"><span><a href="#" onclick="editRow(<%=i%>)">[更新]</a></span></div></td>
  <td><div style="width:60px;"><span><a href="">[删除]</a></span></div></td>
  <td><div style="width:60px;"><span><a href="">[二级]</a></span></div></td>
  </tr>
<%
 }
 }
%>
</table>

js如下:

function editRow(rowIndex) {
 alert(window.groupTable.rows.item(rowIndex).cells.item(2).getElementsByTagName_r('input')[0].value);
}

希望本文所述對大家JavaScript程式設計有所幫助。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn