Javascript DOM HTML Textarea name Property get

Introduction

Get the name of a text area:

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

Click the button to display the value of the name attribute of the text area.

View in separate window

<!DOCTYPE html>
<html>
<body>

<textarea id="myTextarea" name="comment">
Some text in a text area....</textarea>
<button onclick="myFunction()">Test</button>

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

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

</body>
</html>

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

The name attribute can identify form data after a form is submitted.

The name property accepts and returns a boolean type value.




PreviousNext

Related