jQuery Multiple choices


Total available count: 24
Subject - JavaScript Frameworks
Subsubject - jQuery

Which jQuery method returns the direct parent element of the selected element?


 

 

 

 



A


Solution:-

jQuery parent() Method Definition and Usage
The direct parent element of the selected element returns by the parent() method. 

The DOM tree: This method only traverses a single level up the DOM tree. To traverse all the way up to the document's root element (to return grandparents or other ancestors), use the parents() or the parentsUntil() method.

Tip: To traverse a single level down the DOM tree, or all the way down to the last descendant (to return children or other descendants), use the children() or find() method.

Syntax

$(selector).parent(filter);

Example
Return the direct parent element of <span>:

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

 




Next 1 multiple choice(s)

1

The jQuery animate() method can be used to animate ANY CSS property?

Comments