使用方法:
$("input").iCheck("check"); //将输入框的状态设置为checked
$("input").iCheck("uncheck"); //移除 checked 状态
$("input").iCheck("toggle"); //toggle checked state
$("input").iCheck("disable"); //将输入框的状态设置为 disabled
$("input").iCheck("enable"); //移除 disabled 状态
$("input").iCheck("update"); //apply input changes, which were done outside the plugin
$("input").iCheck("destroy"); //移除iCheck样式
调用iCheck时,只需要将修改了默认值的参数列出来即可:
//基础使用方法 $("input").iCheck({ labelHover : false, cursor : true, checkboxClass : "icheckbox_square-blue", radioClass : "iradio_square-blue", increaseArea : "20%" });下面是参数列表及其默认值:
{ handle: "", checkboxClass: "icheckbox", radioClass: "iradio", checkedClass: "checked", checkedCheckboxClass: "", checkedRadioClass: "", uncheckedClass: "", uncheckedCheckboxClass: "", uncheckedRadioClass: "", disabledClass: "disabled", disabledCheckboxClass: "", disabledRadioClass: "", enabledClass: "", enabledCheckboxClass: "", enabledRadioClass: "", hoverClass: "hover", focusClass: "focus", activeClass: "active", labelHover: true, labelHoverClass: "hover", increaseArea: "", cursor: false, inheritClass: false, inheritID: false, insert: "" }我们可以对上面列出的任何class重置样式
使用on()方法绑定事件:
$("input").on("ifChecked", function(event){ //ifCreated 事件应该在插件初始化之前绑定alert(event.type + " callback"); }); bootstrap iCheck中的radio和checkbox的大小可以调整吗?.icheckbox_square-blue, .iradio_square-blue {display: block;margin: 0;padding: 0;width: 22px;height: 22px;background: url(blue.png) no-repeat;border: none;cursor: pointer; }如果要调整icheck的radio或checkbox样式,通过上面的css修改width和height,同时修改blue.png图片对应的尺寸。