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 5 multiple choice(s)

1

Look at the following selector: $(":disabled"). What does it select?

2

Which jQuery method is used to remove selected elements?

3

Look at the following selector: $("p#intro"). What does it select?

4

Is jQuery a W3C standard?

5

Look at the following selector: $("div p"). What does it select?

Comments