Opened 11 years ago
Closed 11 years ago
#12029 closed bug (invalid)
on() not the same as live() for keypress event
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The documentation states on() should be used in place of live for jquery 1.7.
For newly added elements, the 'click' event is working as of 1.7.2 (was broken in previous versions), but 'keypress' does not work with on() (works with live()).
$("input").live( 'keypress', function(event) { if ( event.which == 13 ) { event.preventDefault(); alert("works"); } }); $("input").on( 'keypress', function(event) { if ( event.which == 13 ) { event.preventDefault(); alert("doesn't work"); } });
Note: See
TracTickets for help on using
tickets.
Please ask for help on the forums; You're using .on incorrectly.