jQuery - how to check/uncheck a checkbox

Posted by Renso on Geeks with Blogs See other posts from Geeks with Blogs or by Renso
Published on Fri, 30 Apr 2010 10:33:38 GMT Indexed on 2010/04/30 16:48 UTC
Read the original article Hit count: 250

Filed under:

    $('#PrimaryContacts').unbind().change(function() {


        if ($('#PrimaryContacts option:selected').val() == 0) {


            $('#filterPrimaryContact').removeAttr('checked').trigger('click');


        }


        else {


            $('#filterPrimaryContact').trigger('click');


        }



    });


Also, in the example above, triggering the checkbox does not change the checkbox value. As depicted above, based on a dropdown box changing and no contact being selected from the drop down box, automatically uncheck the checkbox and trigger it in invoke any event handlers on the checkbox.
 

© Geeks with Blogs or respective owner