Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a jquery event for handling edits of text boxes?

Tags:

jquery

I am looking for a way to bind to an event whenever the text of a text box changes. Right now, I have something like this:

$("#inputPane").change(function() { alert("Changed!"); });

However, this only gets called when the text box loses focus. I want to get an event whenever a new character is added, deleted, or a cut/paste occurs.

I'd prefer not to use any third party plugins for this. Using pure jquery would be nicer.

like image 242
Andrew Eisenberg Avatar asked Feb 21 '23 10:02

Andrew Eisenberg


1 Answers

The best option is to use keyup event.

$("#inputPane").keyup(function() {
    alert("Changed!");
});

However you should consider that it will fire whenever ANY key is clicked, even Ctrl, Alt, Shift, etc.

like image 157
VisioN Avatar answered May 15 '23 23:05

VisioN