Obtaining Text Box Value after Chracter has been Typed in jQuery
What is the best way to get the value in a text box after character has been typed in jQuery? I always seem to be missing out o开发者_Python百科n the last character.
$('textbox').keyup(function() {
var value = $(this).val();
});
YOu can use the bind function:
http://api.jquery.com/bind/
$('#textBoxId').bind('keyup keypress', function() {
//Do you stuff
});
$("#textboxId").keyup(function(){
$(this).val()
});
Try catching both change and keyup event
$("#test").bind("onkeyup change",function()
{dosomething($(this).val())});
demo http://jsfiddle.net/RnPcf/
精彩评论