views:

65

answers:

3

How to get the parent node name of the checked child node of ASP.net TreeView Control using jquery/javascript ?

$('#<%=treeMeasures.ClientID%>').find('input[type=checkbox]').each(function() {
                        alert($(this).parent().text());
                    });
A: 

The .parent() function is used to access an elements immediate parent.

You can also use .parents() to access parent elements further up in the ancestry.

You can also include an optional parameter for a filter to a specific selector in either case.

Joey C.
I had tried .parent(). I am unable to retrieve the node name. Well I am putting the sample jquery I had done, which I wanted to retrieve the parent nodes name, in the above question
Sreejesh Kumar
Well my issue is, I wanted to restrict dragging Parent Node from ASP.net TreeView control. I want to drag only child node
Sreejesh Kumar
A: 

Not really a jQuery guru, but if you need to access the id of the parent you could try using

 $(this).parent().attr('id')
ZombieSheep
I think he's looking for the dom attribute ".nodeName" and not the id.
MacAnthony
A: 

If you're willing to get the parent node use $(this).parent().get(0)

if you just need the tag name of the parent Element try $(this).parent().get(0).tagName

Ninja Dude