I'm looking for a way to implement a custom "enterKey" event for jQuery:
$('selector').enterKey(function(){
alert( $(this).val() ) // doesn't work
});
i have done something similar to https://stackoverflow.com/a/5689145/1123630 and it works with one exception: i cannot access $(this) from within my anonymous function
Simplified version of what i want:
$.fn.test = function( ev ) {
ev();
}
$('#val').test( function(){
alert( $(this).val() ); // works well with static text,
//but not with "this" pointer
});
Any help would be apreciated