I have this code:
$j("#regfname").keypress(function () { alert('Handler for .keypress() called.'); });
and want to execute only once ... or just for the first keystroke. What is the best way to do this?
You can use the jQuery one () method to execute only one event per element.
$j("#regfname").one("keypress", function () { alert('Handler for .keypress() called.'); });
You want to use the one function:
one
$j('#regfname').one('keypress', function(){...});