简体   繁体   English

如何使用jquery更改prettyCheckable复选框(选中并取消选中)

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

How do i change prettyCheckable checkbox with jquery, to check and uncheck? 如何使用jquery更改prettyCheckable复选框,以检查和取消选中? 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.. 这些都不起作用,没有一个在视觉上改变了prettyCheckable复选框。

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 如果你正在使用jquery版本jquery 1.6 +使用prop其他使用attr

Here i think remove .change() 在这里我认为删除.change()

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

TO: 至:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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