Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all table ids inside a div using jquery

I have a div having n number of tables, now i want to alert all table ids inside that div only using jquery.

Here is the example code :

<div id="myDiv">

<table id="table1"><tr><td>hello</td></tr></table>

<table id="table2"><tr><td>hello</td></tr></table>

<table id="table3"><tr><td>hello</td></tr></table>

<table id="table4"><tr><td>hello</td></tr></table>

<table id="table5"><tr><td>hello</td></tr></table>

</div>

Assume that i already know div id which is 'myDiv'.

Thanks.

like image 312
deepak.mr888 Avatar asked May 19 '14 10:05

deepak.mr888


1 Answers

Try,

$('#myDiv table').each(function(){ 
   alert(this.id);  
});

Working Demo

like image 54
Rajaprabhu Aravindasamy Avatar answered Sep 27 '22 19:09

Rajaprabhu Aravindasamy