The jQuery parent selector is used
to get the parent element of a specific element.
.parent()
In this post we shall see on how to use the jQuery parent selector to get the parent element of a specific element.
The following script gets the parent element of the td element tdName.
.parent()
In this post we shall see on how to use the jQuery parent selector to get the parent element of a specific element.
The following script gets the parent element of the td element tdName.
alert('Hierarchy Child:' + $("#tdName").attr('id'));
alert('Hierarchy
Parent:' + $("#tdName").parent().attr('id'));
The following script gets the parent element of the td element tdName on click of the btnHierarchySelector button.
$('#btnHierarchySelector).click(function(event) {
event.preventDefault();
//
// Hierarchy - Parent
The following script gets the parent element of the td element tdName on click of the btnHierarchySelector button.
$('#btnHierarchySelector).click(function(event) {
event.preventDefault();
//
// Hierarchy - Parent
alert('Hierarchy
Child:' + $("#tdName").attr('id'));
alert('Hierarchy
Parent:' + $("#tdName").parent().attr('id'));
});
});
Related Post
jQuery hierarchy selector
jQuery first selector
jQuery last selector
jQuery even selector
jQuery odd selector
jQuery only-child selector
jQuery parent selector
jQuery nth-child selector
jQuery index :gt selector
jQuery empty selector
jQuery first selector for Textbox
jQuery last selector for Textbox
jQuery first selector for Dropdown
jQuery last selector for Dropdown
jQuery hierarchy selector Example
jQuery hierarchy selector
jQuery first selector
jQuery last selector
jQuery even selector
jQuery odd selector
jQuery only-child selector
jQuery parent selector
jQuery nth-child selector
jQuery index :gt selector
jQuery empty selector
jQuery first selector for Textbox
jQuery last selector for Textbox
jQuery first selector for Dropdown
jQuery last selector for Dropdown
jQuery hierarchy selector Example
No comments:
Post a Comment