Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to check/uncheck a checkbox input or radio button?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 256
    Comment on it

    First of all check if the checkbox is already checked or not.

    jQuery('#my-checkbox').is(':checked');
    

    If it is not checked then do it checked.

    jQuery('#my-checkbox').attr('checked','checked');
    

    And if it is already checked then make it unchecked.

    jQuery('#my-checkbox').removeAttr('checked');
    

    And if you to check/uncheck all checkboxes.

    // Check anything that is not already checked:
    jQuery(':checkbox:not(:checked)').attr('checked', 'checked');
    
    // Remove the checkbox
    jQuery(':checkbox:checked').removeAttr('checked');
    

    That's it .

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: