jquery: iterating through list items with up and down keys -> cursor position?
hey guys, i have the following case: http://jsfiddle.net/cKf5b/
as you can see when you focus the textfield and you press the UP and DOWN arrow keys you can navigate through the list-items underneath.
i have the following line
//set cursor position
if(keyCode === 38) return false;
in order to keep 开发者_开发问答the cursor position at the end of the text even when pressing the UP key.
I wonder if there is a better way to keep the cursor always at the end of the inputfield. Right now you can see it flicker when you press the UP key. The cursor jumps to the front and then gets set to the end.
any idea how i can stop that flickering?
try adding this code at the end :
$('.s').bind('keydown keypress',function(e)
{
if (e.keyCode == 38 || e.keyCode == 40)
{
e.preventDefault();
}
});
or u can check it in jsfiddle : http://jsfiddle.net/cKf5b/12/
精彩评论