Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12029 closed bug (invalid)

on() not the same as live() for keypress event

Reported by: TrumpetGod@… 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");
	}
});

Change History (1)

comment:1 Changed 7 years ago by mikesherov

Resolution: invalid
Status: newclosed

Please ask for help on the forums; You're using .on incorrectly.

Note: See TracTickets for help on using tickets.