开发者

How to shift focus in jquery?

开发者 https://www.devze.com 2023-01-30 02:00 出处:网络
I have a field and then a button in my form. I have some focus problem in mozilla. So, I decided to do it using focus evnet of jquery. $(\'.button-id\').focus(); is not working for me. So, can i do th

I have a field and then a button in my form. I have some focus problem in mozilla. So, I decided to do it using focus evnet of jquery. $('.button-id').focus(); is not working for me. So, can i do this in jquery: As开发者_Python百科 some one writing in the input field and when hit enter keyword the focus shifts from input field to button.


If you give your input field type="submit", browsers should do this automatically.

Then, if you want your button to do something other than submit the form, you can handle the submit event:

$("#form-id").submit(function() {
    //do something
    return false; //don't submit
});
0

精彩评论

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

关注公众号