Skip to content
Alexey Kupriyanenko edited this page Apr 13, 2015 · 2 revisions

.attr(attributeName)

attributeName The name of the attribute to get.

Get the value of an attribute for the first element in the set of matched elements.

.attr(attributeName, value)

attributeName The name of the attribute to set.

value A value to set for the attribute.

Set one or more attributes for the set of matched elements.

.attr(attributes)

attributes An object of attribute-value pairs to set.

.removeAttr(attributeName)

attributeName An attribute to remove

Remove an attribute from each element in the set of matched elements.

.val()

This method does not accept any arguments.

Get the current value of the first element in the set of matched elements.

.val(value)

Set the value of each element in the set of matched elements.

value A string of text corresponding to the value of each matched element to set as selected/checked.

.css(propertyName, value)

propertyName A CSS property name.

Set one CSS property for the set of matched elements.

.css(properties)

properties An object of property-value pairs to set.

Set CSS properties for the set of matched elements.

.addClass(className)

className One or more space-separated classes to be added to the class attribute of each matched element.

Adds the specified class(es) to each element in the set of matched elements.

.removeClass(className)

className One or more space-separated classes to be removed from the class attribute of each matched element.

Remove a single class, multiple classes, or all classes from each element in the set of matched elements.

.toggleClass(className)

className One or more class names (separated by spaces) to be toggled for each element in the matched set.

.toggleClass(className, state)

className One or more class names (separated by spaces) to be toggled for each element in the matched set.

state A Boolean (not just truthy/falsy) value to determine whether the class should be added or removed.

Add or remove one or more classes from each element in the set of matched elements, depending on either the class's presence or the value of the state argument.

.hasClass(className)

className The class name to search for.

Determine whether any of the matched elements are assigned the given class.