check if checkbox is checked, check uncheck


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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);

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.