css

abbr.control-stick steering joystick control;combat service support combat service support;coded switch system password transfer system;cryogenic storage system cryogenic storage system

jquery css() method syntax

Function:css() method returns or sets one or more style attributes of the matching element.

Return css properties:Return the CSS property value of the first matching element. Shorthand CSS properties (such as "background" and "border") are not supported when used to return a value.

Syntax:$(selector).css(name)'

Parameters:

Parameters Description
name Required. Specifies the name of the CSS property. This parameter can contain any CSS property. For example "color".

Set css properties:Set the specified CSS properties for all matching elements.

Syntax:$(selector).css(name,value)

Parameters:

Parameters Description
name Required. Specifies the name of the CSS property. This parameter can contain any CSS property, such as "color".
value Optional. Specifies the value of a CSS property. This parameter can contain any CSS property value, such as "red". If the empty string value is set, removes the specified attribute from the element.

Use functions to set css attributes:Set the value of the style attribute in all matching elements. This function returns the property value to be set. Accepts two parameters, index is the index position of the element in the object collection, and value is the original attribute value.

Syntax:$(selector).css(name,function(index,value))

Parameters:

Parameters Description
name Required. Specifies the name of the CSS property. This parameter can contain any CSS property, such as "color".
function(index,value) Specifies a function that returns the new value of a CSS property.
index Optional. Accepts the index position of the selector
oldvalue Optional. Accepts the current value of a CSS property.

Set multiple css attributes/values:Set the "name/value pair" object as the style attribute of all matching elements. This is the best way to set a large number of style properties on all matching elements.

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

Parameters:

Parameter Description
{property:value} Required. Specifies the name/value pair object to be set as a style attribute. This parameter can contain several CSS property name/value pairs. For example {"color":"red","font-weight":"bold"}

jquery css() method example

    

This is a paragraph.

This is another paragraph.

Run instance »

Click the "Run instance" button to view the online instance