admin管理员组文章数量:1410724
I need help changing the placeholder
value on a input field with javascript, preferably JQuery.
<input id="someinput" value="" placeholder="Change This With JS" type="text">
I need help changing the placeholder
value on a input field with javascript, preferably JQuery.
<input id="someinput" value="" placeholder="Change This With JS" type="text">
- changing how? Like change the default value of the placeholder using jQuery? Change the functionality of the placeholder by using jQuery (polyfill)? – Joseph Commented Jun 17, 2012 at 4:05
2 Answers
Reset to default 5demo like this: http://jsfiddle/qcNFF/ ?
Good read: http://api.jquery./prop/
code
$(function() {
alert(' Before change => ' + $('#someinput').prop('placeholder'));
$('#someinput').prop('placeholder', "text changed- hulk");
alert(' After change => ' + $('#someinput').prop('placeholder'));
});
here's a quick demo for you:
the fiddle code http://jsfiddle/nickadeemus2002/H7MG7/
just use jquery's .attr() method to changed the string.
本文标签: javascriptchange html form element placeholder with jqueryStack Overflow
版权声明:本文标题:javascript - change html form element placeholder with jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744810257a2626387.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论