jQuery.fn

jQuery.fn

Source:

The jQuery plugin namespace.

Methods

(static) set(attropt, value) → {jQuery}

Set attributes of the selected DOM objects if they haven't changed.

Source:

attr is one of:

  • html
  • text
  • val
  • attr:[name]
  • css:[name]
  • data:[name]
  • prop:[name]

These are called every time (i.e. no value check):

  • addClass
  • removeClass
  • toggleClass:[name]
Example
$('<div>').set('html', 'New text');
$('<input />').set({
  'val': 'New value',
  'prop:disabled': true
});
Parameters:
Name Type Attributes Description
attr String <optional>

The attribute to set.

value * | Object

The attribute value or a set of attribute/values.

Returns:

The selected jQuery object for chaining.

Type
jQuery