Solved

get the id inside a HTMLTableRowElement

Posted on 2012-03-20
2
2,956 Views
Last Modified: 2012-03-20
Hi Experts!

I am using jQuery to get as an array the tr id's for a given filter

var comment = $('tr[id$=comment]').get();
for (var k in comment ) {
	console.log(comment [k]);
}

Open in new window

After executing this code I get in the console the actual <tr> element array like this
<tr style="display: none;" id="[b]name1_comment[/b]">

Open in new window


How one can get the tr id from this?  In jQuery one uses
$(this).attr('id')

Open in new window

in an each, but I would like to know if there is a pure JS way to do it.

Thank you!
0
Comment
Question by:dlcnet
  • 2
2 Comments
 
LVL 13

Accepted Solution

by:
ansudhindra earned 500 total points
ID: 37741346
instead of your "for" statement use this..

$.each(comment,function(k,v){
    $('#res').append($(this).attr('id'));
});

ref: http://jsfiddle.net/Sudhindra/eTr49/
0
 
LVL 13

Expert Comment

by:ansudhindra
ID: 37741348
where $('#res') is the another div for displaying results (in my example).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Angular - "nest" service calls? 18 25
Objects on Same Line 2 18
Redirect Website for Mobile Devises 7 38
ASP.NET gridview select textbox on focus 2 15
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now