Rectangle 27 367

A simpler solution is to do this rather than using uniform:

$('#check1').prop('checked', true); // will check the checkbox with id check1
$('#check1').prop('checked', false); // will uncheck the checkbox with id check1

You can also use:

$('#check1').click(); //

This will toggle the check/uncheck for the checkbox but this will also trigger any click action you have defined. So be careful.

prop()
attr()

Very clean and working answer. Many thanks!

This leaves the checked attribute as-is in jQuery 1.7.1 for me. Works but doesn't do what you think it should.

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 107

Looking at their docs, they have a $.uniform.update feature to refresh a "uniformed" element.

$("input:checkbox").uniform();

$("body").on("click", "#check1", function () {
    var two = $("#check2").attr("checked", this.checked);
    $.uniform.update(two);
});

fyi, this will only work in 1.6+

@mkoryak: Works fine in 1.4.4, but the links to the js and css files were broken. Here's an updated fiddle. If you mean that it'll have issues specifically in 1.6, then that's probably true since jQuery changed then reverted behavior of .attr(). Using 1.6 or higher, you should really be using .prop().

I can see absolutely no difference at all between the updated jsFiddle and the original (right down to the mislabeling of checkbox 2), except the updated version works for me and the original didn't!?!?

good to know is that jQuery actually only calls element.checked = false; for you ;)

did not work for me also jsfiddle does not work or is confusing

Sign up for our newsletter and get our top new questions delivered to your inbox (see an example).

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 24

I think it's better to use the .prop() function instead of .attr(). Otherwise it won't work always as expected ...

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 13

If you are using uniform 1.5 then use this simple trick to add or remove attribute of check Just add value="check" in your checkbox's input field. Add this code in uniform.js > function doCheckbox(elem){ > .click(function(){

if ( $(elem+':checked').val() == 'check' ) {
    $(elem).attr('checked','checked');           
}
else {
    $(elem).removeAttr('checked');
}

if you not want to add value="check" in your input box because in some cases you add two checkboxes so use this

if ($(elem).is(':checked')) {
 $(elem).attr('checked','checked');
}    
else
{    
 $(elem).removeAttr('checked');
}

If you are using uniform 2.0 then use this simple trick to add or remove attribute of check in this classUpdateChecked($tag, $el, options) { function change

if ($el.prop) {
    // jQuery 1.6+
    $el.prop(c, isChecked);
    if (isChecked) {
        $el.attr(c, c);
    } else {
        $el.removeAttr(c);
    }

}

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 7

$('#check1').prop('checked', true).uniform(); 
$('#check1').prop('checked', false).uniform();

Thank you very much. I can confirm that this is the most simple solution.

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 2

$('#checkbox').prop('checked',true).uniform('refresh');

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 1

First of all, checked can have a value of checked, or an empty string.

$("input:checkbox").uniform();

$('#check1').live('click', function() {
    $('#check2').attr('checked', 'checked').uniform();
});

There's nothing wrong with passing a boolean as the value of checked.

But we're not writing HTML markup. We're setting a property on the HTMLInputElement. Have a look at the checked property.

passing a boolean value is only supported in 1.6+, before that you had to set the checked attribute to 'checked' or remove it.

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 0

I think it's better to use the .prop() function instead of .attr(). Otherwise it won't work always as expected ...

How to uncheck checkbox using jQuery Uniform library - Stack Overflow

jquery checkbox
Rectangle 27 0

This is because UniformJs requires that you update your modification on uniform elements if you need to change values on the form dynamically:

exact, that's what i were looking for.

ajax - jQuery Uniform Checkbox does not (un)check - Stack Overflow

jquery ajax checkbox append uniform
Rectangle 27 0

jQuery 1.6.4 changed the meaning of the attr() function, which is used by jquery.uniform.js. attr() now returns the state that the attribute WAS in when the page loaded - not what the state of the attribute is NOW. There is a replacement function called prop(), which does the job that attr() used to do.

See also: https://github.com/pixelmatrix/uniform/pull/167, which attempts to address the issue with better backwards compatibility.

ajax - jQuery Uniform Checkbox does not (un)check - Stack Overflow

jquery ajax checkbox append uniform
Rectangle 27 0

Its been a while but I had the same problem but I resolved it by a simple solution.

Uniform is adding a span over the checkbox and gives it the class checked if it is checked or not, but on page load only. If you check or uncheck the checkbox while the page is already loaded, it will uncheck (or check) but since the span is over it, you will see it as not updated, you have to do it manually.

Might not be the cleanest solution, but works fine on every browser.

This code works fine for me. Second line of code alone did the trick. Thanks

Hey Jean-Francois, this is because Uniform elements need to be updated after modification, I have posted an explanation in this answer.

ajax - jQuery Uniform Checkbox does not (un)check - Stack Overflow

jquery ajax checkbox append uniform
Rectangle 27 0

These methods would work once a syntax has discovered if the element is already checked. Thanks anyway :D

Ahh, misunderstood the problem then :)

ajax - jQuery Uniform Checkbox does not (un)check - Stack Overflow

jquery ajax checkbox append uniform
Rectangle 27 0

I know this may be a bit late, but hopefully it will help someone. I had to add a couple lines to the uniform code so it would look for pre checked checkboxes. This code starts at line 262 for me. I am using Uniform version 1.7.5. The lines between the 'added by John' notes are what I added.

This doesn't work for jQuery 1.6.4, since if(!$(elem).attr("checked")){ only checks if the checkbox was checked when the page was loaded. This is different behaviour than previous versions of jQuery. Use prop instead of attr to determine the current status of "checked".

Excellent John tried Alex's method of changing .attr to .prop on my jquery.uniform.min file but did not fix the problem. Implemented your solution as well as add in Grants change and it worked a treat. Thanks guys. Using jQuery1.6.4 by the way.

ajax - jQuery Uniform Checkbox does not (un)check - Stack Overflow

jquery ajax checkbox append uniform
Rectangle 27 0

$('#all').on('click', function(){
        $(':checkbox').prop("checked",$(this).is(':checked'));
  });

i saw what you did there :) , pretty neat

This works well but no with latest jQuery versions as they have removed attr and added prop instead. SO just update the code and ad prop instead attr and it will work good :)

javascript - jquery uniform select and deselect all checkbox - Stack O...

javascript jquery
Rectangle 27 0

You can disable the click event:

$('#checkbox').unbind('click');

And then handle it like you want with:

$('#checkbox').prop('checked',true);
$.uniform.update();

jquery - Prevent clicking a checkbox in Uniform library - Stack Overfl...

jquery uniform jquery-uniform
Rectangle 27 0

you can use the disable attribute

$('#checkbox').on('click', function(){
    $("#checkbox").attr("disabled", true);
});

that will disable the checkbox once its been clicked leaving it checked

jquery - Prevent clicking a checkbox in Uniform library - Stack Overfl...

jquery uniform jquery-uniform