Textarea placeholder Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

The placeholder property sets or gets the placeholder attribute of a text area.

Set the placeholder property with the following Values

Value Description
text Sets a short hint that describes the expected value of the text area

Return Value

A String, representing a short hint that describes the expected value of the text area

The following code shows how to change the placeholder text of a text area:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
Address:<br>
<textarea id="myTextarea" placeholder="Your address..">
</textarea>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//from  w  w w.java2 s. co  m
    document.getElementById("myTextarea").placeholder = "your address";
}
</script>

</body>
</html>

Related Tutorials