jQuery Multiple choices


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

Which jQuery method is used to set one or more style properties for selected elements?


 

 

 

 



A


Solution:-

Definition and Usage
The CSS() method is used to sets or returns one or more style properties for the selected elements.

When used to return properties:
This method returns the specified CSS property value of the FIRST matched element. However, shorthand CSS properties (like "background" and "border") are not fully supported and may give different results in different browsers.

When used to set properties:
This method sets the specified CSS property for ALL matched elements.

Syntax
Return the CSS property value:

$(selector).css(property);

Set the CSS property and value:

$(selector).css(property,value);

Set CSS property and value using a function:

$(selector).css(property,function(index,currentvalue));

Set multiple properties and values:

$(selector).css({property:value, property:value, ...});

Example
Set the color property of all <p> elements:

$("button").click(function(){
 $("p").css("color", "red");
});

 




Next 5 multiple choice(s)

1

Which jQuery method is used to hide selected elements?

2

With jQuery, look at the following selector: $("div.intro"). What does it select?

3

What is the correct jQuery code to set the background color of all p elements to red?

4

The jQuery html() method works for both HTML and XML documents

5

Is it possible to use jQuery together with AJAX?

Comments