admin管理员组文章数量:1424977
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
本文标签: javascriptHow to change textbox value on key up in jqueryStack Overflow
版权声明:本文标题:javascript - How to change textbox value on key up in jquery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745359120a2655214.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论