62,046
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript">
$(function(){
$("table tr td").each(function(){
$(this).find("[type=button]").click(function(){
alert($(this).parent().parent().find("[type=text]").val());
});
});
});
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://code.jquery.com/jquery-2.0.3.min.js" type="text/javascript"></script>
<title></title>
<script type="text/javascript">
$(function () {
$("input[type=button]").on("click", function () {
alert($(this).parent().prev().find("input").val());
});
})
</script>
</head>
<body>
<div>
<table>
<tr>
<td>
1
</td>
<td>
<input type="text" value="数据1" />
</td>
<td>
<input type="button" value="获取" />
</td>
</tr>
<tr>
<td>
2
</td>
<td>
<input type="text" value="数据2" />
</td>
<td>
<input type="button" value="获取" />
</td>
</tr>
</table>
</div>
</body>
</html>