Sign in

.setAttribute()

Sets a attribute value on all selected elements.

Syntax

neon.setAttribute(string attr, string value)

attr

The name of the attribute to set.

value

The value to set the attribute to. Setting this to the empty string ("") clears the value of the attribute (see also .removeAttribute()).

Requirements

This method should be executed on a selection of elements. Please see the .select() method.

Return value

This method is chainable. It returns a copy of the Neon object on which it was called.

Description

This method allows you to set an attribute value on one or more elements at once.

Many browser and DOM HTML inconsistencies are worked around for your convenience:

  • "class" may be used to set class names (see also .addClass()).
  • "for" may be used to set the HTML for attribute.
  • "style" may be used to set inline styles (see also .style() and .styleRule()).
  • Setting "tabindex" works on all browsers and does not require a capital "I".