DOM manipulation methods

The DOM manipulation methods are discussed in detail in Chapter 5, Manipulating the DOM.

Attributes and properties

Manipulation method

Description

.attr(key)

Gets the attribute named key.

.attr(key, value)

Sets the attribute named key to value.

.attr(key, fn)

Sets the attribute named key to the result of fn (called separately on each matched element).

.attr(obj)

Sets attribute values given as key-value pairs.

.removeAttr(key)

Removes the attribute named key.

.prop(key)

Gets the property named key.

.prop(key, value)

Sets the property named key to value.

.prop(key, fn)

Sets the property named key to the result of fn (called separately on each matched element).

.prop(obj)

Sets property ...

Get Learning jQuery - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.