jQuery focus function not working in Firefox

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

    This should do the trick:

    $(function ()
    {
        $("a").click(function ()
        {
            $($(this).attr("href")).focus();
    
            return false; // remember to stop links default action
        });
    });
    

    Tested in latest version of Chrome, IE and FireFox.

提交回复
热议问题