I want to change the value attribute to placeholder with jQuery. So the result would be something like this
Original
<input type="text" value="Enter name" />
What I want to change above to
<input type="text" placeholder="Enter name" />
I have only found solutions for changing the actuall text between the “” and not the text before those. So replaceWith, replaceAll does’nt seems to work.
Someone having an idea how to solve this?
You may use
.removeAttr('value')to remove attributeExample:
and add new attribute with
.attr('placeholder','Enter name')Example:
As suggested by
rcdmkYou may do it chaining the method: