javascript - change html form element placeholder with jquery - Stack Overflow

I need help changing the placeholder value on a input field with javascript, preferably JQuery.<inpu

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">

Share asked Jun 17, 2012 at 4:03 BlakeinatorBlakeinator 651 silver badge4 bronze badges 1
  • 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
Add a ment  | 

2 Answers 2

Reset to default 5

demo 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744810258a4595016.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信