html---textarea初始化时就有个table空格以及tab键操作无效

1 初始化时就有一个tab空格
    这是由于<textarea></textarea>之间的内容不为空的原因,包含空格和换行,否则浏览器会觉得空格或者换行都是文本域的内容。因此书写时需将<textarea></textarea>紧靠在一起。
2 tab键对textarea操作无效
    在textarea中使用tab键时是无效的。会切换到还有一个控件上去,可是当我们有个须要时,要可以在文本域中使用tab键,可以使用javascript或者jquery方式实现:
    方式1:javascript
    tabIndent.js
    <script src="http://julianlam.github.com/tabIndent.js/js/tabIndent.js"></script><!-- 导入tabindent.js脚本-->
    <script>tabIndent.renderAll();</script><!-- 应用脚本-->
    在textarea标签中的class="tabIndent"
    实例:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>

<style type="text/css">
.demo{600px; margin:30px auto; color:#51555c}
.demo h3{height:32px; line-height:32px; font-size:18px}
.demo h3 span{float:right; font-size:32px; font-family:Georgia,serif; color:#ccc;
overflow:hidden}
.demo textarea{600px;height:50px;}
</style>

<script src="tabIndent.js"></script>
</head>
<body>
    <div class="demo">
    <textarea name="saytxt" id="saytxt" class="tabIndent"></textarea>
    <script>tabIndent.renderAll();</script>
    </div>
</body>
</html>
    
原文地址:https://www.cnblogs.com/zfyouxi/p/5204474.html