利用JavaScript實現動態顯示表格且對應改變按鍵的value值

來源:互聯網
上載者:User

標籤:charset   utf-8   fun   cin   pre   nbsp   content   round   onclick   

插入的代碼並沒有符合HTML5樣式,只是為了實現利用JS動態顯示表格,並且按鍵的value值會同時發生變化的功能。
 1 <!DOCTYPE > 2 <html > 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 </head> 6 <body> 7 <table width="760" border="0" cellspacing="0" cellpadding="0"> 8     <tr > 9         <td bgcolor="#00CCFF">222</td>10         <td  bgcolor="#00CCFF">333</td>11         <td  bgcolor="#00CCFF">444</td>12     </tr>13     <tr >14         <td bgcolor="#00CCFF">555</td>15         <td  bgcolor="#00CCFF">666</td>16         <td  bgcolor="#00CCFF">777</td>17     </tr>18 </table>19 20 21 <form name="form1" >22     <input name="ok" type="button" id="ok" value="顯示" onclick="history_data(‘divc‘);" />23     24     <table id="divc" width="760" border="0" cellspacing="0" cellpadding="0"  style=" display:none">25             <tr >26                 <td bgcolor="#9966FF">table2 222</td>27                 <td bgcolor="#9966FF">table2 333</td>28                 <td bgcolor="#9966FF">table2 444</td>29             </tr>30             <tr>31                <td bgcolor="#9966FF">table2 555</td>32                 <td bgcolor="#9966FF">table2 666</td>33                 <td bgcolor="#9966FF">table2 777</td>34             </tr>35     </table>36 </form>37 38 <script>39 function history_data(TagName) {40    var obj = document.getElementById(TagName);41    if (document.form1.ok.value=="顯示")42    {43      document.form1.ok.value="隱藏";44          obj.style.display = ""; 45    }46    else47    {48      document.form1.ok.value="顯示";49      obj.style.display = "none";50    }51 }52 </script>53 54 </body>55 </html>

 

利用JavaScript實現動態顯示表格且對應改變按鍵的value值

聯繫我們

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