js給html標籤 賦值

來源:互聯網
上載者:User
textarea 標籤 -- 代表HTML表單多行輸入欄位

  • textarea標籤是成對出現的,以<textarea>開始,以</textarea>結束
  • 屬性:
    • Common -- 一般屬性
    • cols -- 多行輸入欄位的列數
    • rows -- 多行輸入欄位的行數
    • alt -- 代表表單的提示文字,當滑鼠停留時
    • accesskey -- 表單的快速鍵訪問方式
    • disabled -- 輸入欄位無法獲得焦點,無法選擇,以灰色顯示,在表單中不起任何作用
    • readonly -- 輸入欄位可以選擇,但是無法修改
    • tabindex -- 輸入欄位,使用"tab"鍵的遍曆順序
  • 引用網址:http://www.dreamdu.com/xhtml/tag_textarea/

沒見value屬性,但實際還可用,賦值時用innerText、innerHTML、value都可以,如下:

<html>
<head></head>

<script type="text/javascript">
function changeTextArea(){

document.getElementById("myTextArea").innerText=document.getElementById("myTextArea").innerText+"/ninnerText is ok!";
document.getElementById("myTextArea").innerHTML=document.getElementById("myTextArea").innerText+"/ninnerHTML is ok!";
document.getElementById("myTextArea").value=document.getElementById("myTextArea").innerText+"/nvalue is ok!";
}

</script>

<body>

<textarea name= "myTextArea" cols= "80 " rows= "10 ">原始值</textarea>
<input type="button" value="按鈕" onclick="changeTextArea()"/>
</body>
</html>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.