HTML DOM Textarea wrap Property

HTMLDOMWeb DevelopmentFront End Technology

The HTML DOM Textarea wrap property returns and modify the value of wrap attribute of a text area element in an HTML document.

Syntax

Following is the syntax −

1. Returning wrap

object.wrap

2. Adding wrap

object.wrap = soft | hard

Let us see an example of HTML DOM Textarea wrap Property:

Example

Live Demo

<!DOCTYPE html>
<html>
<style>
   body {
      color: #000;
      height: 100vh;
   }
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem 0;
   }
   .show {
      font-size: 1.5rem;
      margin: 1rem 0;
   }
</style>
<body>
<h1>DOM Textarea wrap Property Demo</h1>
<form action='' method="post">
<textarea rows="5" cols="28" wrap="soft">
Hi! I'm a text area element with some dummy text.
</textarea>
<input type="submit" class='btn' value="Submit Form">
</form>
<button onclick="set()" class="btn">Show wrap value</button>
<div class="show"></div>
<script>
   function set() {
      document.querySelector('.show').innerHTML = "The value of wrap attribute is " + document.querySelector("textarea").wrap;
   }
</script>
</body>
</html>

Output

Click on “Show wrap value” button to display the value of wrap attribute of the textarea element.

raja
Published on 20-Sep-2019 14:55:26
Advertisements