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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744810258a4595016.html
评论列表(0条)