Loading…

What is parent() in jQuery?

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"});
});

Suggest An Answer

No suggestions avaliable!

Latest post from JQuery interview questions

Ask Question