HTML DOM wordSpacing 属性
JavaScript基础 2022-06-08 14:52:2217小码哥的IT人生shichen
HTML DOM wordSpacing 属性
定义和用法
wordSpacing 属性设置文本中的单词间距。
语法:
Object.style.wordSpacing=normal|length
可能的值
值 | 描述 |
---|---|
normal | 默认。定义单词间的标准空间。 |
length | 定义单词间的固定空间。 |
实例
本例改变单词间的间距:
<html> <head> <script type="text/javascript"> function changeWordSpacing() { document.getElementById("p1").style.wordSpacing="10px";
} </script> </head> <body> <p id="p1">This is an example paragraph</p> <input type="button" onclick="changeWordSpacing()" value="Change space between words" /> </body> </html>
TIY
完整实例【wordSpacing - 改变单词间的间距】:
<html> <head> <script type="text/javascript"> function changeWordSpacing() { document.getElementById("p1").style.wordSpacing="10px"; } </script> </head> <body> <p id="p1">This is an example paragraph</p> <input type="button" onclick="changeWordSpacing()" value="Change space between words" /> </body> </html>
可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html