开发者

keyup() bug in Firefox and Chrome?

开发者 https://www.devze.com 2022-12-18 04:45 出处:网络
$(\'input\').keyup(function(e){ var k = e.keyCode ? e.keyCode : e.which; console.log(k); }); . <input type=\"text\" name=\"\"autocomplete=\"off\"/>
 $('input').keyup(function(e){
  var k = e.keyCode ? e.keyCode : e.which;          
  console.log(k);  

  });

.

    <input type="text" name=""  autocomplete="off"/>

Why keyup fires twice but only after second strike for special keys (arrows, space, backspace etc) ? - Are any solutions to fix this issue? - the autocomplete it's turned off - In IE it is working fine - With keydown or keypress is working fine for FF and Chrome - But I can't use keypress because it doesn't work for IE for special keys - I can't use keydown because I need the value of the input including the character I just type. Like this $(this).val(); - (I needed it for a live search). Keydown will give the value but witho开发者_StackOverflowut the last char. Maybe you could give me an idea in this direction - how to capture the value including last char with keydown?


Based on your question I'm a bit confused, will combining keyup and .val() not do what you want?

$('input').keyup(function(e){
  liveSearchFunction($(this).val());
});

If not please elaborate a bit more.

0

精彩评论

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

关注公众号