jQuery Multiple choices


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

Which jQuery method is used to switch between adding/removing one or more classes (for CSS) from selected elements?


 

 

 

 



D


Solution:-

jQuery toggleClass() Method Definition and Usage
The jQuery toggleClass() Method toggles between adding and removing one or more class names from the selected elements.

The jQuery toggleClass() Method checks each element for the specified class names. The class names are added if missing, and removed if already set - This creates a toggle effect.

However, by using the "switch" parameter, you can specify to only add, or only remove a class name.

Syntax

$(selector).toggleClass(classname,function(index,currentclass),switch)

Example
Toggle between adding and removing the "main" class name for all <p> elements:

$("button").click(function(){
 $("p").toggleClass("main");
});

 




Next 5 multiple choice(s)

1

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

2

Is jQuery a W3C standard?

3

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

4

Which jQuery method is used to remove selected elements?

5

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

Comments