Javascript DOM HTML Textarea type Property get

Introduction

Find out which type of form element a text area element is:

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

Click the button to return which type of form element the text area is.

View in separate window

<!DOCTYPE html>
<html>
<body>

<textarea id="myTextarea" rows="4" cols="50">
At java2s.com you will learn how to make a website. 
</textarea>
<button type="button" onclick="myFunction()">Test</button>

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

<script>
function myFunction() {//from   ww w .  ja  v  a  2  s  . c om
  var x = document.getElementById("myTextarea").type;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

The type property returns which type of form element a text area is.

For a text area object this will always be "textarea".




PreviousNext

Related