Changing the "placeholder" attribute of HTML5 input elements dynamically using Javascript

Viewed 76979

I'm trying to dynamically update the HTML5 placeholder attribute of a text field using jQuery.

$("textarea").attr("placeholder", "New placeholder text");

From Firebug, I can observe that the placeholder attribute is indeed changing. But in the rendered textarea element, it stays the same. Any suggestions?

6 Answers

HTML:

<input type="text" placeholder="entername" id="fname"/>

JS:

$("#fname").attr("placeholder", "New placeholder text");
Related