Opened 13 years ago
Closed 13 years ago
#5252 closed bug (invalid)
attr adding an event to an input field does not work in IE but does in Firefox
Reported by: | johnH | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | unfiled | Version: | 1.3.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Using $(":input").attr("onfocus","alert(this.id);"); to add an event action to an input field will work in Firefox but not in IE (version 8.0.6001). Please see attached example.
Attachments (1)
Change History (4)
Changed 13 years ago by
comment:1 Changed 13 years ago by
Is there a reason that you would want to do it this way instead of the event methodology in jQuery?
Here's how you should be doing it:
$(":input").focus(function(e) { alert(this.id); }); /* -- OR -- */ $(":input").bind('focus',function(e) { alert(this.id); });
More information is available in the Events section of the documentation: http://docs.jquery.com/Events
comment:3 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Don't set event handlers using .attr().
Note: See
TracTickets for help on using
tickets.
Example of attr not working correctly in IE.