HTML DOM Textarea wrap属性

HTML DOM Textarea wrap Property

HTML DOM Textarea wrap属性返回并修改HTML文档中文本区域元素的wrap属性的值。

句法

以下是语法-

1.返回包装

1
object.wrap

2.添加包装

1
object.wrap = soft | hard

让我们看一个HTML DOM Textarea wrap属性的示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!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>
DOM Textarea wrap Property Demo
<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>


 function set() {
   document.querySelector('.show').innerHTML ="The value of wrap attribute is" + document.querySelector("textarea").wrap;
 }

</body>
</html>

输出量

单击"显示换行值"按钮以显示textarea元素的换行属性的值。