jQuery Uniform Checkbox does not (un)check

后端 未结 8 1935
借酒劲吻你
借酒劲吻你 2020-12-14 00:15

I am using jQuery Uniform to style inputs/selects etcs. However, the checkbox has stopped working. I am appending data sent from an ajax call. Once it\'s loaded

相关标签:
8条回答
  • 2020-12-14 01:15

    You don't need to change .attr() to .prop():

        "click.uniform touchend.uniform": function(){
            if(!$(elem).attr('checked')){
                //box was just unchecked, uncheck span
                spanTag.removeClass(options.checkedClass);
    
                //Added by PingOn
                $(elem).removeAttr('checked');
                //end addition by PingOn
    
                // Added by John
            }else if(!$(elem).is(':checked')){
                spanTag.removeClass(options.checkedClass);
                // end addition by john
    
                //Added by PingOn
                $(elem).removeAttr('checked');
                //end addition by PingOn
            }else{
                //box was just checked, check span.
                spanTag.addClass(options.checkedClass);
    
                //Added by PingOn
                $(elem).attr('checked','true');
                //end addition by PingOn
          }
    
    0 讨论(0)
  • 2020-12-14 01:17

    Couldn't you use something like

    $("#checkbox").attr("checked", "true");
    

    to make the checkbox checked, and

    $("#checkbox").removeAttr("checked");
    

    to uncheck it?

    0 讨论(0)
提交回复
热议问题