Posted By

tomaszsimon on 12/22/09


Tagged

check checkbox checked uncheck


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

wattsupnow


check if checkbox is checked, check uncheck


 / Published in: jQuery
 

URL: http://drupal.org/node/116548

source: http://www.electrictoolbox.com/check-uncheck-checkbox-jquery/

  1. if($('#chkId:checked').val() != null)
  2. {
  3. // checked
  4. }
  5.  
  6. //or
  7.  
  8. if($('#chkId:checked').length != 0)
  9. {
  10. // checked
  11. }
  12.  
  13. //or
  14.  
  15. $('input[name=foo]').is(':checked')
  16. $('input[name=foo]').attr('checked')
  17.  
  18. // check uncheck
  19. $('input[name=foo]').attr('checked', true);

Report this snippet  

You need to login to post a comment.