Home >Web Front-end >JS Tutorial >jquerymobile checkbox needs to be refreshed in time to obtain its accurate value_jquery

jquerymobile checkbox needs to be refreshed in time to obtain its accurate value_jquery

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:54:211029browse

Solution:

Copy code The code is as follows:

$('input[type="checkbox "]').bind('click',function() {
$(this).prop('checked').checkboxradio("refresh"); // The binding event updates the checked value of the checkbox in time
});

If you want to use js to change the value of the checkbox, you must refresh it in time.
Copy code The code is as follows:

$('input [type="checkbox"]' ).attr('checked',false).checkboxradio("refresh");
$('input [type="checkbox"]').attr('checked',false).checkboxradio("refresh") ;

Cause: jquerymobile cannot re-render after manually changing its value. In this way, the value displayed on the page is different from the actual value. (jquerymobile hides all form elements, and then uses js to add some elements to beautify the effects of input, select, textarea and other elements)
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