The implementation method of jQuery to get the number of table rows and output the cell content

This article mainly introduces the implementation method of jQuery to obtain the number of table rows and output the cell content, involving jQuery's dynamic operation skills for table and page elements. Friends who need it can refer to the following

 

The example in this article describes how jQuery gets the number of table rows and outputs the cell content. Share for your reference, the details are as follows:

js part:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<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 part:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<form id="form1" runat="server">

  <div>

  <input type="text" id="txtInput" runat="server" style=" font:" />

  <br/>

  <asp:Label ID="lblMessage" Text="我在测试" 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>

Readers who are more interested in jQuery related content can check the special topics on this site: " jQuery table (table) operation skills summary ", " jQuery operation DOM node method summary ", " jQuery extension skills summary ", " jQuery common plug-ins and usage summary " ", " Summary of jQuery dragging effects and techniques ", " Summary of Ajax usage in jquery ", " Summary of common classic special effects of jQuery ", " Summary of jQuery animation and special effects usage " and " Summary of jquery selector usage "

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326219284&siteId=291194637