Thu marlo Thu marlo - 1 year ago 85
jQuery Question

jquery how to get Name of parent

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

var a = $(this).parent();

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

Answer Source

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

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


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

        alert($(a[0]).attr('name')); //Attribute (real) name
        alert(a.attr('name')); //Attribute (real) name
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download