我使用的是一个使用iCheck v1.0.2的引导模板
当我创建这样的输入时:
<input id="follow_us" type="checkbox">
生成结果:
<div class="icheckbox_minimal-grey" style="position: relative;">
<input id="follow_us" type="checkbox" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);">
<ins class="iCheck-helper" style="position: absolute; top: -20%; left: -20%; display: block; width: 140%; height: 140%; margin: 0px; padding: 0px; border: 0px; opacity: 0; background: rgb(255, 255, 255);"></ins>
</div>
我想检测这个复选框上的变化。正如文档所说,有一个方法:
$('#follow_us').on('ifChanged', function(event){
alert(event.type + ' callback');
});
但这绝对没有任何作用。其他回调也一样。我错过什么了吗?
看起来您没有将复选框初始化为iCheck对象。为此,您需要在以下行中添加一些内容:
$('#follow_us').iCheck();
在iCheck回调工作之前,将添加到脚本中。查看文档(上面的链接)以获取更多关于初始化时可以设置的选项的信息。