如何jquery遍历一个TR列表中所有控件?

szu_john 2011-07-15 01:47:49
如题。
...全文
1150 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
szu_john 2011-07-15
  • 打赏
  • 举报
回复
谢谢各位,问题已解决,结贴。
zell419 2011-07-15
  • 打赏
  • 举报
回复
$("#trTest td select,#trTest td :text").each(function () {
//do something
});
少了个"#" ,- - .
zell419 2011-07-15
  • 打赏
  • 举报
回复
$("#trTest td select,trTest td :text").each(function () {
//do something
});
遍历DropDownList TextBox 。
guotongyu1 2011-07-15
  • 打赏
  • 举报
回复
$("#trTest td select");asp控件在程序加载前会将服务器控件编译成html控件
DropDownList 就会成为普通的select
TextBox 是input type=text
但是id不会改
接下来你就应该明白了
$("#trTest td select").each(function () {
//do something
});
szu_john 2011-07-15
  • 打赏
  • 举报
回复
例如有如下的一个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>

hongmei85 2011-07-15
  • 打赏
  • 举报
回复
这样?
<!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>
guotongyu1 2011-07-15
  • 打赏
  • 举报
回复
什么控件?第几行的tr;

87,907

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧