Home >Web Front-end >JS Tutorial >Introduction to the use of jquery prop and the difference with attr_jquery

Introduction to the use of jquery prop and the difference with attr_jquery

WBOY
WBOYOriginal
2016-05-16 17:08:19923browse

Prop and attr have similar functions

Same point: both can get and set attribute values
Difference: When processing checkbox, it is recommended to use prop, because IE browser is not compatible, because It is similar to all individuals. It is recommended to use prop
when removing attributes: removeProp("xxx")
Example:
Get attribute value

Copy Code The code is as follows:

var currentChecked=$(".my-checked").prop("checked"); The value is true/false

Set attribute value
Copy code The code is as follows:

var currentChecked= $(".my-checked").prop("checked",false);
Statement:
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