Textarea name Property - Change the name of a text area: - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Description

Textarea name Property - Change the name of a text area:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<textarea id="myTextarea" name="comment">
Some text in a text area....</textarea>

<button onclick="display()">Display name</button>
<button onclick="change()">Change name</button>

<script>
function display() {
    var x = document.getElementById("myTextarea").name;
    console.log("The name of the text area is: " + x);
}

function change() {/*from  www  .  j  av a  2 s .  co m*/
    var x = document.getElementById("myTextarea").name = "newTxtName";
    console.log("The name was changed to: " + x);
}
</script>

</body>
</html>

Related Tutorials