views:

298

answers:

3
<input type="text" id="name" />
<span id="display"></span>

So that when user enter something inside "#name",will show it in "#display"

+5  A: 

You could simply set input value to the inner text or html of the #display element, on the keyup event:

$('#name').keyup(function () {
  $('#display').text($(this).val());
});
CMS
+4  A: 
$('#name').keyup(function() {
    $('#display').text($(this).val());
});
janoliver
A: 

The previous answers are, of course, correct. I would only add that you may want to prefer to use the keydown event because the changes will appear sooner:

$('#name').keydown(function() {
    $('#display').text($(this).val());
});
Jan Zich