JQuery Prop () method

Source: Internet
Author: User

Tags: remove UNC Note the Dex style should jquer the collection back

Add and remove attributes that are de-removed as ' color ':

$ (' button '). Click (function () {

var $x = $ (' div ')

$x. Prop (' Color ', ' f00 ')

$x. Append (' The color attribute: ' + $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: theprop () 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


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: