Reputation: 2019
I have an <input Id="inputTest">
and I have tried grabbing the value, $('#inputTest').val();
but the problem is when a user types text it does not hold it in the value until the form is submitted.
How can I capture what the user types in before submitting the form?
Upvotes: 0
Views: 52
Reputation: 5361
I was working on the Demo when a correct answer Popped up :)) anyway Lets not get it to waste. Yes thats correct. (keyup)
Demo
$(document).on("keyup", "#input", function(event){
var txt = $(this).val();
$("#text").html(txt);
});
Upvotes: 2
Reputation: 34416
You can us keyup()
to get the value as it is entered -
$('input[name="foo"]').keyup(function() {
$('#foo_result').html( $(this).val() );
});
Upvotes: 1