JS的屬性操作(2)

來源:互聯網
上載者:User

標籤:http   代碼   下拉框   元素   htm   button   分享   nload   inpu   

1.點擊下拉框選擇資訊

2.點擊按鈕,下拉框內選擇的資訊會自動跳轉到文本輸入框

 

 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5 <title>無標題文檔</title> 6  7 <script> 8 /* 9     HTML 的屬性操作:讀、寫10         屬性名稱:11         屬性值:12         13         讀操作:擷取、找到14         元素.屬性名稱15         16         寫操作:“添加?”、替換、修改17         元素.屬性名稱 = 新的值18         19 */20 window.onload = function (){21     var oBtn = document.getElementById(‘btn1‘);22     var oText = document.getElementById(‘text1‘);23     var oSelect = document.getElementById(‘select1‘);24 25     oBtn.onclick = function (){26         //oBtn.value = ‘button‘;27         //oText.value = 123;28         oText.value = oSelect.value;29     };30 };31 </script>32 33 </head>34 35 <body>36 37 <input id="text1" type="text" />38 <select id="select1">39     <option value="北京">北京</option>40     <option value="上海">上海</option>41     <option value="杭州">杭州</option>42 </select>43 <input id="btn1" type="button" value="按鈕" />44 45 </body>46 </html>
範例程式碼:

 

JS的屬性操作(2)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.