html---textarea初始化時就有個table空格以及tab鍵操作無效,textarea空格
1 初始化時就有一個tab空格 這是因為<textarea></textarea>之間的內容不為空白的原因,包括空格和換行,否則瀏覽器會認為空白格或者換行都是文本域的內容,因此書寫時需將<textarea></textarea>緊靠在一起;2 tab鍵對textarea操作無效 在textarea中使用tab鍵時是無效的,會切換到另一個控制項上去,但是當我們有個需要時,要能夠在文本域中使用tab鍵,可以使用javascript或者jquery方式實現: 方式1:javascript <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{width: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{width: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>