javascript - If you want to cancel your checked attribute in the ifChecked method in iCheck, it does not work
过去多啦不再A梦
过去多啦不再A梦 2017-05-19 10:28:52
0
1
955

When using the iCheck plug-in,

<label for="taoda" class="rad_chx_label" style="margin-right:20px;">
    <input type="checkbox" id="pro1" name="isHaveDefaultProduct" value="1" />
            <span style="margin-left:8px;">是</span>
                </label>
<label for="remin" class="rad_chx_label">
     <input type="checkbox" id="pro2" name="isHaveDefaultProduct" value="0"  checked />
            <span style="margin-left:8px;">否</span>
    </label>

Simply define two labels
js as follows:

$(function(){
$('input[type=checkbox]').iCheck({    //注册复选框
  checkboxClass: 'icheckbox_minimal-green',
});
  $('input[type=checkbox]').on('ifChecked', function(event){ 
             em=$(this);//alert(event.type + ' callback');  
             if(em.val()=="1"){
                em.iCheck('uncheck');
             }
             
});  
        });

will be found in

 if(em.val()=="1"){
                    em.iCheck('uncheck');
                 }
em.iCheck('uncheck'); in

does not work, that is, when you click the check box with value 1, it is immediately set to the unselected state after being selected,,,,
What should you do? What about writing?

过去多啦不再A梦
过去多啦不再A梦

reply all(1)
某草草

If I remember correctly, there is a toggle, just use that one.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!