Jquery form text
Is it possible to type some text in form text field and at the same time see that text in DIV beside, without submitting the form first?
Something like:
<input type="text" name="t开发者_StackOverflow中文版ext" id="text"/>
<div class="show_text_here"></div>
How about something like this:
$('#text').keyup(function(){
$('.show_text_here').html($(this).val());
}
It's not only possible, it's happening right here right now!
At its simplest, you'll just need to bind a handler to the proper event (.keyup() probably... check http://api.jquery.com/category/events) of that input and the only thing the handler needs to do is set the contents of the div to the value in the input.
There's a discussion on this same topic here: http://forum.jquery.com/topic/how-to-display-value-of-input-in-div-object-in-real-time
This code will do copy the value of the text box in real-time:
$('#text').keypress(function(){
$('.show_text_here').html($(this).val());
});
精彩评论