开发者

prevent change event in jquery accordion

开发者 https://www.devze.com 2023-01-05 04:07 出处:网络
I am using Jquery ui accordion , in that i have a text box as a accordion header , now when i am 开发者_StackOverflow社区trying

I am using Jquery ui accordion , in that i have a text box as a accordion header , now when i am 开发者_StackOverflow社区trying to type a space in text box accordion change and changestart event fire so how would i prevent this thing while typing space in a input box


use

  • .preventDefault()
  • .stopPropagation()

within a keydown or keypress or keyup event handler. You can check the keyCode or even better the value of which from the event object there and execute both functions from above.

Alternativly, you can just return false; which actually will trigger the same functions for you.

Example:

$('input:text').bind('keypress', function(event){
   if(event.which === 32)
      return(false);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号