开发者

jQuery/Javascript auto tab index lock/select?

I have a simple display project and want to cut out the mouse from the equation, the page only has one field (a search field) and I开发者_如何学Python want the browser to be locked into to the field remove the need for a mouse while keeping it user friend for those who don't know how to maneuver without a mouse.

Can it be done with jQuery/Javascript? I don't really know what im search for besides it may have something to do with tab indexing.

Thanks,

Arthur


Since Gaby hasn't edited, I'll go ahead and write up the solution. Some of the credit for the code goes to Gaby and Andy E.

$(document).ready(function(){
   var el = $(':text:eq(0)');
   el.focus();
   el.blur(function(){ 
             setTimeout(function() { el.focus(); },0);
           });
});


if you mean that you want the field item to be focused (so that the user can start typing in it right away) then

$(document).ready(function(){
   $(':text:eq(0)').focus();
});

this will put the focus inside the first input box it will find in the page..

(the :eq(0) can be omitted if you only have one input box ..)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜