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

jQuery1.9.1 adjustment method for checkbox (prop)_jquery

WBOY
Release: 2016-05-16 16:50:33
Original
1173 people have browsed it

In the version of jquery 1.8.x, our operations for selecting and unchecking the checkbox are as follows:

Determine whether to select

Copy code The code is as follows:

$('#checkbox').prop('checked ')

Set checked and unchecked status:

Copy code The code is as follows:

$('#checkbox').attr('checked ',true)
$('#checkbox').attr('checked',false)

But this method is handled differently in jquery1.9.1

In IE10, Chrome, FF, for the selected state, $('#checkbox').attr('checked',true) can be achieved for the first time
But when the selection is cleared through code, the next time it is cleared through code $('#checkbox').attr('checked',true) When selecting
although there is checked='checked' in the code, there is no check in the screen performance.
This problem does not exist under IE8 and IE6.

Later I investigated the relevant information and found that now attr('checked',true) has been replaced by prop('checked',true)

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!