jquery - Getting the second level parent of an element
Posted
by j-man86
on Stack Overflow
See other posts from Stack Overflow
or by j-man86
Published on 2010-04-20T13:10:24Z
Indexed on
2010/04/20
13:13 UTC
Read the original article
Hit count: 243
I am trying to retrieve the parent of an element's parent (grandparent?). I want to find that grandparent, then find a tag in that element, then store that text as a variable to publish elsewhere on the page. I've been trying to use the parent() function but without success.
Here's the code I tried:
$('.mixPlayCell a').click( function() {
var title = $(this).parent().get(0).parent().get(0).text();
alert(title);
});
Thanks!
© Stack Overflow or respective owner