Add and remove attributes that are de-removed as ' color ':
$(‘button‘).click(function () {
var $x = $(‘div‘)
$x.prop(‘color‘, ‘f00‘)
$x.append(‘The color Attributes:‘ + $x.prop(‘color‘))
$x.removeProp(‘color‘)
})
The prop () method sets or returns the attributes and values of the selected element.
Returns the value of the first matching element when a property value is returned;
When setting property values, set one or more property/value pairs for the matching element collection
Note:
the prop () method should be used to retrieve property values , such as DOM properties;
To retrieve HTML attributes, use the attr () method instead;
To remove an attribute, use the Removeprop () method
eg:
returns the value of the property : $ (selector). Prop (the name of the specified property)
set properties and Values : $ (selector). Prop (the name of the specified property, the value of the specified property)
use functions to set properties and values : $ (selector). Prop (Specifies the name of the property, function (retrieves the index position of the element in the collection, retrieves the current property value of the selected element))
set multiple properties and values : $ (selector). Prop ({The name of the specified property: The value of the specified property, the name of the specified property: The value of the specified property, ...})
JQuery Prop () method