I would like to ask you about something that does not work for me ? If you could help me please.
Html:
You're obviously using jQuery, so you could define the keyup event in your script as well:
HTML/PHP
JavaScript
$(".blabla").keyup(function(e) {
console.log("pressed key with code", e.keyCode, "on id", this.id);
});
The anonymous function passed as a handler in $(...).keyup(handler)
receives the jQuery Event you're looking for. Within that function this
is set to the DOM Element the event is attached to, in this case the input
field.
If you intend to work on that field, like using .val()
you'd have to wrap it in the $(...)
first:
$(".blabla").keyup(function(e) {
var $input = $(this)
console.log("current value is", $input.val());
});
Just keep in mind, that the value might not have changed, when you're using keydown
instead of keyup
.
For more infos on that, take a look at the jQuery-API