Implementation method of jQuery getting the number of rows of table and outputting the contents of cells

  • 2021-07-01 06:16:31
  • OfStack

This article example shows that jQuery gets the number of rows of table and outputs the cell contents. Share it for your reference, as follows:

js section:


<script language="javascript" type="text/javascript">
$(function() {
  $("#txtInput").attr("value", "90");
  var v_temp = $("#lblMessage").text();
  //alert(v_temp);
  $("#txtInput01").attr("value", v_temp);
  $("#div1").removeClass("div1");
  $("#div1").addClass("divtest");
  var flog = $("#div1").hasClass("divtest");
  $("#div1").html("<input type='button' id='id123' style='width:100px; height:150px'>");
  var t01 = $("#table01 tr").length;
  alert(t01);
  $("#table01").find("td").each(function(i) {
    var t = $(this).text();
    alert(t);
  })
});
</script>

HTML section:


<form id="form1" runat="server">
  <div>
  <input type="text" id="txtInput" runat="server" style=" font:" />
  <br/>
  <asp:Label ID="lblMessage" Text=" I'm testing " runat="server"></asp:Label>
  <br/>
  <input type="text" id="txtInput01" runat="server" />
    <br />
    <asp:TextBox ID="TextBox1" runat="server" Width="156px"></asp:TextBox>
    <input type="button" onclick="createXMLHttpRequest()" />
    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
  </div>
   <table id="table01" border="1px"><tr>
  <td>11</td><td>11</td></tr>
  <tr><td>22</td><td>22</td></tr>
  <tr><td>33</td><td>33</td></tr>
  <tr><td>44</td><td>44</td></tr>
  <tr><td>55</td><td>55</td></tr></table>
  <div id="div1" class="div1">
  </div>
</form>

For more readers interested in jQuery related content, please check the topics of this site: "Summary of jQuery Form (table) Operation Skills", "Summary of jQuery Operation DOM Node Method", "Summary of jQuery Extension Skills", "Summary of jQuery Common Plug-ins and Usage", "Summary of jQuery Drag Effects and Skills", "Summary of Ajax Usage in jquery", "Summary of jQuery Common Classic Special Effects", "Summary of jQuery Animation and Special Effects Usage" and "Summary of jquery Selector Usage"

I hope this article is helpful to everyone's jQuery programming.


Related articles: