JQuery change not firing until blur

according to the right answer here Javascript change event on input element fires on only losing focus

you should do something like this

$('#name').on('change textInput input', function () {
       
});

however I found that having both textInput and input events can cause the event to fire twice, you don't want that, so just do

$('#name').on('change input', function () { ...


you can do this. just make sure you give the textarea an id tag

$(document).ready(function(){
        $('.addtitle').keyup(function(event) {
            if(event.keyCode==13) { 

}
});
});

in my case here, im firing the function on the enter key (like facebooks functions).

EDIT: also if you have more then one textarea on a page, you should do this:

$(document).ready(function(){
        $('textarea[name=mynamevalue]').keyup(function(event) {
            if(event.keyCode==13) { 

}
});
});

Unfortunately the browser only recognises a change when the field blurs, so you might want to try attaching a keyup listener. Not the most elegant solution, unfortunately.

Details at http://api.jquery.com/keyup/.

Tags:

Jquery