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



jquery get checkbox status (2)

You can use pretty checkable functions:

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

and

$('#part_PAC-050-0142').prettyCheckable('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..


Answer #1

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