开发者

How to stop cursor from jumping to beginning/end of textbox on up/down key?

How can I prevent th开发者_如何学Pythone cursor from jumping to the beginning or end of a textbox when up or down arrow key is pressed, using JavaScript and jQuery?


<input type="text" />


$("input:text").keydown(function(e){
   if(e.which == 38 || e.which == 40) 
       e.preventDefault();
});

You can prevent default on the up and down arrow keys.

http://jsfiddle.net/C5ZCE/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜