Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 17:08:19
Original
891 people have browsed it

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);
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