简体   繁体   中英

How to change prettyCheckable checkbox with jquery (check and uncheck)

How do i change prettyCheckable checkbox with jquery, to check and uncheck? I tried everything.. Actually i'm able to change, the checkbox checks and unchecks, but visually doesn't change.. I tried numerous ways:

$('#part_PAC-050-0142').attr('checked', true); 
$('#part_PAC-050-0142').attr("checked","checked");
$('#part_PAC-050-0142').prop("checked", true).change();
$("ul > li > div > href", "#radio_parts").addClass("checked");
$('#part_PAC-050-0142').addClass("checked", true);
$('#part_PAC-050-0142').triggerHandler("click");

$('input.prettyC').prettyCheckable();

None of this worked, none changed visually the prettyCheckable checkbox..

You can use pretty checkable functions:

$('#part_PAC-050-0142').prettyCheckable('check');

and

$('#part_PAC-050-0142').prettyCheckable('uncheck');

if u are using jquery version jquery 1.6 + use prop else use attr

Here i think remove .change()

$('#part_PAC-050-0142').prop("checked", true).change();

TO:

$('#part_PAC-050-0142').prop("checked", true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM