Search code examples
jquerykeyup

keyup is not firing


I had this working but it has stopped. The weird thing is that 'mouseup' works but 'keyup' does not.

$(document).ready(function () {

 $('#chordprodiv').on('keyup mouseup', 'textarea', function () {
    chordpro_toCHORDSHEET();
});

});

Here is 2 fixes after the comments. I updated jquery and changed the function to .on, and I corrected the event format so they are in the same string. The code was already in the document.ready but I added that for clarity.

I have since targeted the parent div and identified the 'textarea' selector as per another suggestion.

Also here's the html

 <textarea id="chordpro" name="chordpro"></textarea>

Solution

  • .live is deprecated in newer versions of jQuery, you should be using .on

    Additionally your events should be together in one string...

    $('#chordpro').on('keyup mouseup', function () {
        chordpro_toCHORDSHEET();
    });
    

    The event handler should be called in the format, as shown below. $( document ).on( events, selector, data, handler );