jQuery focus function not working in Firefox

后端 未结 7 640
执念已碎
执念已碎 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:28

    You could also be more explicit and call preventDefault on the event arg.

    $(document).ready(function()
    {
        $("a").click(function(event) {
            var field_id = $(this).attr("href");
            $(field_id).focus()
            event.preventDefault();
        });
    
    });
    

提交回复
热议问题