Trying to grab the table ID from table id=”1″
in below html / script
when click on Account or Bill link I would like to grab the table ID so I could pass that table ID to another function to grab AJAX data. table ID is crated dyno. this is test data
<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>
1 Answer