Javascript DOM HTML Textarea placeholder Property get

Introduction

Get the placeholder text of a text area:

var x = document.getElementById("myTextarea").placeholder;

Click the button to display the placeholder text of the text area.

View 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() {//w  ww .ja v a  2  s . com
  var x = document.getElementById("myTextarea").placeholder;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related