Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  187] [ 5]  / answers: 1 / hits: 35227  / 13 Years ago, wed, july 27, 2011, 12:00:00

im searching for the Element whicht Provides the Name of a Parent. This:



            $('.Item').click(function(){
var a = $(this).parent();
alert(a[0].tagName);
});


just says DIV, but I need the real name of a Element. Thanks


More From » jquery

 Answers
57

Try the following (Alerts the tag name, and then the Real Name) :



I used $(a[0]).attr('name');



e.g.



$('.Item').click(function() {
var a = $(this).parent();
alert(a[0].nodeName.toLowerCase()); //Tag Name

alert($(a[0]).attr('name')); //Attribute (real) name
//OR
alert(a.attr('name')); //Attribute (real) name
});

[#90983] Tuesday, July 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aricl

Total Points: 215
Total Questions: 91
Total Answers: 94

Location: Venezuela
Member since Thu, Jul 15, 2021
3 Years ago
;