jQuery focus function not working in Firefox

后端 未结 7 620
执念已碎
执念已碎 2020-12-21 22:16

The following piece of code focuses the text input after you click on the link. It works fine for Chrome 2.x, IE8 and Opera 9.64 but not on Firefox 3.0.9. The text input f

7条回答
  •  一向
    一向 (楼主)
    2020-12-21 22:39

    As hinted by Daniel, the problem is the #text_field on the link. After setting the focus, Firefox is wanting to jump to that named location in the document. All you need to do is return false from your click handler.

    $(field_id).focus();
    return false;
    

提交回复
热议问题