尝试在单击帐户或账单链接时从下面的 html / 脚本中的表 id="1" 中获取表 ID 我想获取表 ID,以便我可以将该表 ID 传递给另一个函数以获取 AJAX 数据。表 ID 是装箱测功机。这是测试数据
<html>
<head>
<script src="jquery-1.8.2.min.js"></script>
<script type = "text/javascript">
$(document).ready(function() {
$('.toggler').click(function(event){
event.preventDefault();
$(this).parent().find('.content').slideToggle();
var a = $(this).next("div").find(".content").children().attr("id");
alert(a);
});
</script>
</head>
<body>
<table border="1">
<tr>
<td>
<table id="MainTable">
<tr>
<td>
<div class="toggler-wrap">
<a href="#" class="toggler">Account </a>
<a href="#" class="toggler">Bill</a>
<div class="content">
<table id="1">
<tr><td>Content will come here</td></tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table id="MainTable">
<tr>
<td>
<div class="toggler-wrap">
<a href="#" class="toggler">Account</a>
<a href="#" class="toggler">Bill</a>
<div class="content">
<table id="2">
<tr><td>Content will come here</td></tr>
</table>
</div>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>