Javascript Reference - HTML DOM Textarea wrap Property








The wrap property sets or gets the wrap attribute of a textarea.

The wrap attribute specifies how the text is wrapped when submitted in a form.

Browser Support

wrap Yes Yes Yes Yes Yes

Syntax

Return the wrap property.

var v = textareaObject.wrap

Set the wrap property.

textareaObject.wrap=soft|hard




Property Values

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

Return Value

A String type value representing how the textarea wraps text when submitted in a form.

Example

The following code shows how to get the wrap settings in a textarea.


<!DOCTYPE html>
<html>
<body>
<form action="url">
<textarea id="myTextarea" rows="2" cols="20" name="usrtxt" wrap="hard">
this is a test<!-- ww w.jav a 2s .  c  o  m-->
</textarea>
</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 code above is rendered as follows: