Reputation: 833
I just want to change the VALUE attribute of textbox on key up. But when I am typing something the value remains same in the mark up. I want to change it in mark up too. Here is my jsfiddle .
MARK UP
<input type="text" value="Type Your Name" id="textBox1" />
<span id="userName"></span>
jQuery
$("#textBox1").keyup(function () {
$("#userName").text($(this).val());
});
Any help would be highly appreciated.
Upvotes: 0
Views: 6853
Reputation: 1
You could also access the textbox via:
$("#textBox1").keyup(function () {
$("#userName").text($('#textBox1').val());
});
http://jsfiddle.net/#&togetherjs=kTauiAAFgR
Upvotes: 0
Reputation: 7997
add this line to your code:
$("#textBox1").attr('value', $(this).val())
check your updated fiddle http://jsfiddle.net/h5tpk/6/
Upvotes: 4