Jacopo Rizzi Jacopo Rizzi - 5 months ago 11
Javascript Question

disable keypress event on event change

I have a slider of questions. I want only the click of a few radio input the change event is active on my slider. But if you accidentally press a keyboard button still activates the slider.
is there any way to disable the keypress event change?

$($slider).change(function () { // funzione principale.
if (currentNodeNum != lastNodeNum){
cleanArray();
}
nextNode();
rightSlider();
});

Answer

You can use this code:

$('#your-checkbox-or-radio').keydown(false);

$($slider).change(function () {
  if (currentNodeNum != lastNodeNum){
    cleanArray();
  }
  nextNode();
  rightSlider();
});
Comments