Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to set check-box with a certain value checked in jquery?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 117
    Comment on it

    To set a checkbox checked with a certain value we use a function prop() with the attribute selector.

    $('selector').prop('checked', true);
    

    For example:

    <input class="chkbox"  name="ex[]" type="checkbox" value="0">0
    <input class="chkbox"  name="ex[]" type="checkbox" value="1">1
    

    Suppose we want to set checkbox true where value is equal to 1 with jquery. For this, we will add the following script:

    $('input.chkbox[value="1"]').prop('checked', true);
    

 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: