search

Home  >  Q&A  >  body text

javascript - If you want to cancel your checked attribute in the ifChecked method in iCheck, it does not work

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梦2804 days ago1027

reply all(1)I'll reply

  • 某草草

    某草草2017-05-19 10:30:52

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

    reply
    0
  • Cancelreply