1.

What is parent() in jQuery?

Answer»

parent() method refers to top-level ELEMENTS in GIVEN HTML objects, usually selected by JQUERY selector. Parent method is used to manipulate changes to be done at the top level of a nested HTML object.

Example: A paragraph which contains a COUPLE of list elements can be a parent. Usually, Parent is used if there is an action based on the child element or if there is any specific need for a parent to be TREATED differently.

Example

$(document).ready(function(){
    $("span").parent().css({"display": "block", "border": "1px solid red"});
});



Discussion

No Comment Found