iCheck jQuery阻止自定义脚本

iCheck jQuery阻止自定义脚本,jquery,onclick,icheck,Jquery,Onclick,Icheck,我使用“iCheck jQuery”来修改复选框的样式。但是当我添加iCheck脚本时,我的onlick metod停止工作。为什么会这样 <input id="my_cb" type="checkbox" value="yes_n" onclick="hide_row_metod()"/> <script> $(document).ready(function(){ $('#my_cb').iCheck({ checkbox

我使用“iCheck jQuery”来修改复选框的样式。但是当我添加iCheck脚本时,我的onlick metod停止工作。为什么会这样

<input id="my_cb"  type="checkbox" value="yes_n" onclick="hide_row_metod()"/>
    <script>
    $(document).ready(function(){
      $('#my_cb').iCheck({
        checkboxClass: 'icheckbox_square-blue',
        radioClass: 'iradio_square-blue',
        increaseArea: '20%' // optional
      });
    });    
    </script>

$(文档).ready(函数(){
$('my#u cb').iCheck({
checkboxClass:'icheckbox_square-blue',
无线电课堂:“伊拉迪奥广场蓝”,
increaseArea:'20%'//可选
});
});    
我的剧本:

<script>
   function hide_row_metod() {
     if(document.getElementById('my_cb').checked){
        document.getElementById('row1').style.display = "none";
     }else{
            document.getElementById('row1').style.display = "inline";
          }
     }
</script>

函数hide_row_metod(){
if(document.getElementById('my_cb')。选中){
document.getElementById('row1').style.display=“无”;
}否则{
document.getElementById('row1').style.display=“inline”;
}
}

它可能被
iCheck
脚本覆盖。尝试仅使用jQuery:

$('#my_cb').on('click', function() {
    $('#row1').css('display', this.checked ? 'none' : 'inline');
});
注册可侦听的自定义事件。我提出了一个,主要的区别是:

$("#my_cb").on("ifChanged", hide_row_metod);
有两个事件:。如果要捕获对复选框的所有更改,则需要同时侦听这两个复选框,或者只侦听
ifChanged
。这将用于切换行,因为您正在测试
hide\u row\u metod
中的
checked

在我的示例中,我使用了块元素
div#row1
,因此在选中和取消选中后,它将以不同的方式(
inline
)呈现


另外:您的方法名称有一个输入错误(缺少
h
)。

我知道这个问题已经问了很久了。我制作了一个脚本,从每个radio/checkbox捕获onclick属性,并将其附加到相应的iCheck/iRadio。请记住在应用iCheck后运行它。设置超时或在iCheck实现后运行它:

$("[class*='icheckbox'],[class*='iradio']").each(function(){
  $(this).find("ins").attr("onclick", $(this).find("input").attr("onclick"));
});

应用iCheck后检查呈现的HTML