Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 7 years ago

#1440 closed bug (fixed)

.focus() doesn't fire for 'a' (anchor) element

Reported by: rworth Owned by: john
Priority: major Milestone: 1.1.4
Component: event Version: 1.1.3
Keywords: focus event anchor Cc:
Blocked by: Blocking:

Description

This is a regression from 1.1.2 to 1.1.3.x:

<a id="myLink">This should be focused.</a>

<script type="text/javascript">

$(function() {

$("#myLink").focus();

});

</script>

Expected: The link receives focus, visible by an outline

Actual: The link does not receive the focus

Cause: I've traced this to the trigger: function jQuery\event\event.js (r1765, line 132)

-if ( fn && val !== false )

+if ( fn && val !== false && !jQuery.nodeName(element, 'a') )

Change History (7)

comment:1 Changed 13 years ago by john

Owner: set to john

comment:2 Changed 13 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev [2529].

comment:3 Changed 9 years ago by anonymous

this appears to be broken again :)

comment:4 Changed 9 years ago by anonymous

It's broken again

comment:5 Changed 8 years ago by anonymous

Still broken! :/

comment:6 Changed 8 years ago by dmethvin

If something is broken we will need a test case. This one works fine for me:

http://jsfiddle.net/pj55k/

You *must* have an href for the element to be focusable.

comment:7 Changed 7 years ago by anonymous

You should write like that

<script type="text/javascript"><![CDATA[

$(window).load(function () {

$("#YourID").focus();

});]]>

</script>

Note: See TracTickets for help on using tickets.