JN_newbie
JN_newbie

Reputation: 6062

Get The table id in JQuery

I have made three html tables with id's are "table1","table2" and "table3". I am able to get the id of first table. How to get Id of all three tables and then show these Id in output using JQuery. For e.g Table Id's are : "table1" then "table2" and then "table3"

Upvotes: 1

Views: 9179

Answers (2)

Giorgio Luparia
Giorgio Luparia

Reputation: 846

I suppose you're using a selector on some other properties, since I miss the point of getting IDs you already know. By the way, you can cycle on your selected set with each() and get your Element's IDs. Example:

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

Upvotes: 0

Gaurav
Gaurav

Reputation: 28755

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

Upvotes: 6

Related Questions