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

Which jQuery method should be used to deal with name conflicts?

2

Which jQuery function is used to prevent code from running, before the document is finished loading?

3

What scripting language is jQuery written in?

4

What is the correct jQuery code for making all div elements 100 pixels high?

5

Which jQuery method is used to perform an asynchronous HTTP request?

Comments