Reputation: 65
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">
Upvotes: 3
Views: 4211
Reputation: 1359
here's a quick demo for you:
the fiddle code http://jsfiddle.net/nickadeemus2002/H7MG7/
just use jquery's .attr() method to changed the string.
Upvotes: 1
Reputation: 34107
demo like this: http://jsfiddle.net/qcNFF/ ?
Good read: http://api.jquery.com/prop/
code
$(function() {
alert(' Before change => ' + $('#someinput').prop('placeholder'));
$('#someinput').prop('placeholder', "text changed- hulk");
alert(' After change => ' + $('#someinput').prop('placeholder'));
});
Upvotes: 5