停止keydown从冒泡滚动

时间:2011-05-22 19:49:29

标签: javascript jquery events keydown event-bubbling

我正在尝试使用keydown函数创建一个向左和向右移动的滑块,并用特定于每个li的内容替换div。然而,当您连续按键过快时,有时内容既不会显示也不会重复,而且事件会冒泡。我尝试了一些方法,但没有任何方法可行。网址为http://jackjamesmartin.ninoharris.com/

1 个答案:

答案 0 :(得分:0)

var wait = false;
function theEvent(){
   if(wait){
     return;
   }
   wait = true;

   do somthing

   //You need to make sure that this is in the callbacks, ie all events are complete.
   wait = false;

  // or setTimeout(function(){wait = false}, xxx )
}