I have input text element, I want: when I write some symbol in this input, alert this symbol,
that is if I write symbol “a”, immediately alert(“a”), how to make this? I trying, but it not working
$("input").on("keypress", function () {
setTimeout (function () {
var search_word = $(this).val();
if ( search_word.length > 0 ) {
alert(search_word);
}
},200);
});
You are having problems with the variable scope.
thisrefers to the inner function..Use this instead:
JSFIDDLE