HTML,单击在table中某一行按钮,怎么获得该行的数据并放到另外的文本框中?

知极诚明 2018-01-07 03:32:52
HTML,单击在table中某一行按钮,怎么获得该行的数据并放到另外的文本框中?
...全文
5513 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_43454098 2020-06-15
  • 打赏
  • 举报
回复
引用 5 楼 天际的海浪 的回复:
[quote=引用 4 楼 m0_37891883 的回复:] [quote=引用 2 楼 jslang 的回复:]

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="tab">
	<tr><td>aaaaa</td><td><input type="button" value="button" /></td></tr>
	<tr><td>bbbbb</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ccccc</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ddddd</td><td><input type="button" value="button" /></td></tr>
</table>
<input type="text" id="text" />
<script type="text/javascript">
$(function(){
	$("#tab").on("click", ":button", function(event){
		$("#text").val($(this).closest("tr").find("td").eq(0).text());
	});
});
</script>
</body>
</html>
一行有多个单元格怎么办啊[/quote] eq(0)就是第一个单元格 eq(1)就是第二个单元格 eq(2)就是第三个单元格[/quote] 请问怎么在这段代码中EL表达式的值该怎么传递给JSP呢?
weixin_43454098 2020-06-14
  • 打赏
  • 举报
回复
引用 5 楼 天际的海浪 的回复:
[quote=引用 4 楼 m0_37891883 的回复:] [quote=引用 2 楼 jslang 的回复:]

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="tab">
	<tr><td>aaaaa</td><td><input type="button" value="button" /></td></tr>
	<tr><td>bbbbb</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ccccc</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ddddd</td><td><input type="button" value="button" /></td></tr>
</table>
<input type="text" id="text" />
<script type="text/javascript">
$(function(){
	$("#tab").on("click", ":button", function(event){
		$("#text").val($(this).closest("tr").find("td").eq(0).text());
	});
});
</script>
</body>
</html>
一行有多个单元格怎么办啊[/quote] eq(0)就是第一个单元格 eq(1)就是第二个单元格 eq(2)就是第三个单元格[/quote] 请问怎么在这里面加上跳转到另一个jsp文件的代码?
--zjy 2019-11-23
  • 打赏
  • 举报
回复
为什么我点击一次是undifined,之后都能获得
天际的海浪 2018-01-07
  • 打赏
  • 举报
回复
引用 4 楼 m0_37891883 的回复:
[quote=引用 2 楼 jslang 的回复:]

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="tab">
	<tr><td>aaaaa</td><td><input type="button" value="button" /></td></tr>
	<tr><td>bbbbb</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ccccc</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ddddd</td><td><input type="button" value="button" /></td></tr>
</table>
<input type="text" id="text" />
<script type="text/javascript">
$(function(){
	$("#tab").on("click", ":button", function(event){
		$("#text").val($(this).closest("tr").find("td").eq(0).text());
	});
});
</script>
</body>
</html>
一行有多个单元格怎么办啊[/quote] eq(0)就是第一个单元格 eq(1)就是第二个单元格 eq(2)就是第三个单元格
知极诚明 2018-01-07
  • 打赏
  • 举报
回复
引用 2 楼 jslang 的回复:

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="tab">
	<tr><td>aaaaa</td><td><input type="button" value="button" /></td></tr>
	<tr><td>bbbbb</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ccccc</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ddddd</td><td><input type="button" value="button" /></td></tr>
</table>
<input type="text" id="text" />
<script type="text/javascript">
$(function(){
	$("#tab").on("click", ":button", function(event){
		$("#text").val($(this).closest("tr").find("td").eq(0).text());
	});
});
</script>
</body>
</html>
一行有多个单元格怎么办啊
知极诚明 2018-01-07
  • 打赏
  • 举报
回复
天际的海浪 2018-01-07
  • 打赏
  • 举报
回复

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title> 页面名称 </title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<table id="tab">
	<tr><td>aaaaa</td><td><input type="button" value="button" /></td></tr>
	<tr><td>bbbbb</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ccccc</td><td><input type="button" value="button" /></td></tr>
	<tr><td>ddddd</td><td><input type="button" value="button" /></td></tr>
</table>
<input type="text" id="text" />
<script type="text/javascript">
$(function(){
	$("#tab").on("click", ":button", function(event){
		$("#text").val($(this).closest("tr").find("td").eq(0).text());
	});
});
</script>
</body>
</html>
知极诚明 2018-01-07
  • 打赏
  • 举报
回复

39,083

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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