attr
UK ['ətr] US ['ətr]
abbr.attractive attractive, charming
jquery attr() method syntax
Function: attr() method sets or returns the attribute value of the selected element. Depending on the parameters of the method, the way it works is also different.
Return attribute value: Return the attribute value of the selected element.
Syntax: $(selector).attr(attribute
##Parameters:
Description | |
Specifies the attribute whose value is to be obtained. |
Set attributes/values: Set the attributes and values of the selected element.
Syntax: $(selector).attr(attribute, value
Parameters:
Description | |
Specifies the name of the attribute. | |
Specifies the value of the attribute. |
Use functions to set attributes/values: Set the attributes and values of the selected elements.
Syntax: $(selector).attr(attribute,function (index,oldvalue))
Parameters:
Description | |
Specifies the name of the attribute. | |
Specifies the function that returns the attribute value . This function can receive and use the index value of the selector and the current attribute value. |
is the selected element Set more than one attribute and value.
Syntax:$(selector).attr({attribute:value, attribute:value ...})
Description | |
Specify one or more attribute/value pairs. |