Home > Web Front-end > JS Tutorial > The difference between jQuery's attr() and prop()

The difference between jQuery's attr() and prop()

韦小宝
Release: 2017-11-27 09:54:47
Original
1527 people have browsed it

jQuery's attr() and prop() are both used to get and set properties, but they are different. If you are interested in jQuery, you can take a look and learn jQuery~


##attr( ) is generally used to set default values, prop() is generally used to set attribute values, that is, for attributes like "diabled", "checked", "selected", attr() only stores their initial values. And prop() stores the value of their real-time state.

When processing the attributes that the HTML element itself has, prop() is generally used

The difference between jQuerys attr() and prop()

When processing our custom attributes of the HTML element, attr is generally used ()

The difference between jQuerys attr() and prop()

The difference between jQuerys attr() and prop()

The above is the entire content of this chapter. If you are interested, you can search for more on

PHP中文网 Oh~

Related recommendations:

jquery form validation plug-in

jquery realizes the opening animation effect of The Matrix

jQuery method of operating the Nth element

jQuery realizes div following the mouse movement Code example

The above is the detailed content of The difference between jQuery's attr() and prop(). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template