mardi 4 août 2015

Why is this my jQuery keypress() event not working?

I have a text box

<input id="textinput" type="text" name="text_input" value=""/>

and a properly linked (did a console.log in the document ready function and it worked) jquery file

$(document).ready(function()
{
    console.log("hi");

});

$( '#textinput' ).keypress(function() {

    var tag_text = $('#textinput').val();
    console.log("key pressed");

});

As far as I can tell, I'm doing everything properly. However, I am obviously not doing something right.

My goal is to make it so that whenever a letter/character (or any key, really) is pressed with focus on the textinput textbox, an event will trigger.

What am I doing wrong here?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire