87,902
社区成员
发帖
与我相关
我的任务
分享
...
<input class = "button" id = "one" value = "展开" />
<table>
....
....
</table>
<script type = "text/javascript">
$(".button").click(function () {
var $id = $(this).attr("id");
var table = document.getElementById("one"); //换成 document.getElementById(); 报错提示 不支持此属性或方法,我就是想获得 $id 的 id ,然后获得 class 为button后面的 table 让table 展开, 因为有不少相同的table 要展开
$(table).show(1000);
});
</script>
$(document).ready( function() {
$(".button").click( function() {
$(this).next("table:eq(0)").show(1000);
});
});
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="http://www.wanmei.com/public/js/jq_132.js"></script>
</head>
<body>
<input class = "button" type="button" block = "one" value = "展开" />
<table id="one" style=" display:none">
<tr>
<td>11111111</td>
</tr>
</table>
<script type="text/javascript">
$(".button").click(function () {
var $id = $(this).attr("block");
$('#'+$id).show(1000);
});
</script>
</body>
</html>