I have this code:
$j("#regfname").keypress(function () {
alert('Handler for .keypress() called.');
});
and want to execute only once... or only for the first keypress ..what's the most optimal way to do it?
You can use the jQuery one() method to only execute the event once per element.
$j("#regfname").one("keypress", function () {
alert('Handler for .keypress() called.');
});
You want to use the one
function:
$j('#regfname').one('keypress', function(){...});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With