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.
wrap |
Yes | Yes | Yes | Yes | Yes |
Return the wrap property.
var v = textareaObject.wrap
Set the wrap property.
textareaObject.wrap=soft|hard
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. |
A String type value representing how the textarea wraps text when submitted in a form.
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: