开发者

How to get the focus on a textbox on a key press

We have a page which requires user to enter some input and post submission (e.g. by hitting开发者_开发百科 Enter key or Submit button). The answer is shown to the end user and we provide a link which says 'Press any key to continue'.

The focus on the input box is automatically shown, either after pressing any key or by clicking on the link. Can someone provide some sample code to do this?


Try this:

$('#other').click(function() {
    $('#target').focus();
});


$("a").mousedown(function(){
    alert('keypressed');
});

$.keypress(function(){
    alert('keypressed');
});


try this too...

 $('#link').click(function() {
        $('#inputbox').focus();
    });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜