mercredi 1 juin 2016

how to check/uncheck a checkbox on keyup

I have been trying to make a script that checks and unchecks a checkbox when I press the 'c' key but it doesn't work.

$(document).keyup(function(e){
  if(e.which == 67){
    if($('#main').css('opacity') == 0) {
    if ($('#cHideChat').attr('checked')) {
    $('#cHideChat').prop('checked', false);
    }
    else {
    $('#cHideChat').prop('checked', true);
      }
    }
  }
});




Aucun commentaire:

Enregistrer un commentaire