这篇文章主要介绍了jQuery获取table行数并输出单元格内容的实现方法,涉及jQuery针对表格与页面元素的动态操作技巧,需要的朋友可以参考下
本文实例讲述了jQuery获取table行数并输出单元格内容。分享给大家供大家参考,具体如下:
js部分:
?
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部分:
?
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 > |
更多关于jQuery相关内容感兴趣的读者可查看本站专题:《jQuery表格(table)操作技巧汇总》、《jQuery操作DOM节点方法总结》、《jQuery扩展技巧总结》、《jQuery常用插件及用法总结》、《jQuery拖拽特效与技巧总结》、《jquery中Ajax用法总结》、《jQuery常见经典特效汇总》、《jQuery动画与特效用法总结》及《jquery选择器用法总结》