Javascript DOM HTML Textarea wrap Property get

Introduction

Find out how the text in a text area should be wrapped:

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

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

View in separate window

<!DOCTYPE html>
<html>
<body>

<form action="/action_page.php">
Address:<br>
<textarea id="myTextarea" rows="2" cols="20" name="usrtxt" wrap="hard">
Main Street//from   w  ww.  j  a  va2s .c om
</textarea>
<input type="submit">
</form>


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

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

<script>
function myFunction() {
  var x = document.getElementById("myTextarea").wrap;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

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

The wrap attribute sets how the text in a text area is to be wrapped.

Property Values

Value Description
soft The text is not wrapped when submitted in a form. Default
hard The text is wrapped when submitted in a form.

When "hard" is used, the cols attribute must be specified

The wrap property returns a String representing how the text area wraps text when submitted in a form.




PreviousNext

Related