#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 16 years ago by
Owner: | set to john |
---|
comment:2 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:6 Changed 12 years ago by
If something is broken we will need a test case. This one works fine for me:
You *must* have an href for the element to be focusable.
comment:7 Changed 10 years ago by
You should write like that
<script type="text/javascript"><![CDATA[
$(window).load(function () {
$("#YourID").focus();
});]]>
</script>
Fixed in SVN rev [2529].