如何jquery遍历一个TR列表中所有控件? 如题。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这样?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <meta http-equiv="content-type" content="text/html; charset=gb2312"> <title> new document </title> <meta name="keywords" content=""> <meta name="description" content=""> <script type="text/javascript" src="js/jq.js"></script> </head><script type="text/javascript"><!-- $(document).ready(function(){$("#kk").children().each(function(){alert($(this).html())})}); $(document).ready(function(){$("#kk input").each(function(){alert(this.outerHTML)})});//--></script> <body> <table> <tr id="kk"> <td>a</td> <td><input type="text" name="dfds"></td> <td><input type="checkbox" name="sd34" value=""/></td> <td><div id="dfsd">dfsa</div></td> </tr> </table> </body></html> 例如有如下的一个tr,我要将其中所用的控件还原成页面初始化时的值,应该如何遍历 <tr id="trTest"> <td class="dinput"><asp:DropDownList id="droYZ" runat="server"></asp:DropDownList></td> <td class="dinput"><asp:TextBox id="txtJB" runat="server" CssClass="textbox" Width="100%"></asp:TextBox></td> <td class="dinput"><asp:DropDownList id="droYD" runat="server"></asp:DropDownList></td> <td class="dinput"><asp:DropDownList id="droTS" runat="server"></asp:DropDownList></td> <td class="dinput"><asp:DropDownList id="droXZ" runat="server"></asp:DropDownList></td> </tr> $("#trTest td select");asp控件在程序加载前会将服务器控件编译成html控件DropDownList 就会成为普通的select TextBox 是input type=text但是id不会改接下来你就应该明白了$("#trTest td select").each(function () { //do something }); $("#trTest td select,trTest td :text").each(function () { //do something });遍历DropDownList TextBox 。 $("#trTest td select,#trTest td :text").each(function () { //do something });少了个"#" ,- - . jquery验证数字问题 JQuery的表格插件Datatables怎样设置成‘可调整’,急急急 想问一个问题 alert不执行 刚开始学习JavaScript,想请教下怎么调试! *** 很有意思的问题,有关image 请问用什么语句对一个下拉列表进行,插入,清空,操作 为什么parseInt的结果是这样啊? 在javascript中用什么函数来去掉首尾的空格 网页小白关于 基于百度地图做网页的一些问题 关于cookie最近浏览商品,谢谢 ext中this.getrow()问题
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<title> new document </title>
<meta name="keywords" content="">
<meta name="description" content="">
<script type="text/javascript" src="js/jq.js"></script>
</head>
<script type="text/javascript">
<!--
$(document).ready(function(){$("#kk").children().each(function(){alert($(this).html())})});
$(document).ready(function(){$("#kk input").each(function(){alert(this.outerHTML)})});
//-->
</script>
<body>
<table>
<tr id="kk">
<td>a</td>
<td><input type="text" name="dfds"></td>
<td><input type="checkbox" name="sd34" value=""/></td>
<td><div id="dfsd">dfsa</div></td>
</tr>
</table>
</body>
</html>
<td class="dinput"><asp:DropDownList id="droYZ" runat="server"></asp:DropDownList></td>
<td class="dinput"><asp:TextBox id="txtJB" runat="server" CssClass="textbox" Width="100%"></asp:TextBox></td>
<td class="dinput"><asp:DropDownList id="droYD" runat="server"></asp:DropDownList></td>
<td class="dinput"><asp:DropDownList id="droTS" runat="server"></asp:DropDownList></td>
<td class="dinput"><asp:DropDownList id="droXZ" runat="server"></asp:DropDownList></td>
</tr>
DropDownList 就会成为普通的select
TextBox 是input type=text
但是id不会改
接下来你就应该明白了
$("#trTest td select").each(function () {
//do something
});
//do something
});
遍历DropDownList TextBox 。
//do something
});
少了个"#" ,- - .