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.
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.
Share Improve this question asked Mar 16, 2014 at 22:42 Fazil MirFazil Mir 8332 gold badges10 silver badges26 bronze badges 1- your submited code working good for me! what is the problem!? – peiman F. Commented Mar 16, 2014 at 23:52
3 Answers
Reset to default 4add this line to your code:
$("#textBox1").attr('value', $(this).val())
check your updated fiddle http://jsfiddle/h5tpk/6/
just wrap your code in
$(function(){
});
http://jsfiddle/h5tpk/5/
You could also access the textbox via:
$("#textBox1").keyup(function () {
$("#userName").text($('#textBox1').val());
});
http://jsfiddle/#&togetherjs=kTauiAAFgR
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745359120a4624279.html
评论列表(0条)