標籤:images idt meta set 地方 lock 努力學習 bcg table
鎮場詩:
清心感悟智慧語,不著世間名與利。學水處下納百川,舍盡貢高我慢意。
學有小成返哺根,願鑄一良心部落格。誠心於此寫經驗,願見文者得啟發。
——————————————————————————————————————————
code:
<!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title><style type="text/css"> .testDiv{ height:150px; width:150px; } td{ height:30px; width:60px; } .bcgRed{ background-color:red; } .bcgGreen{ background-color:green; } .bcgBlue{ background-color:blue; } .current{ background-color:burlywood; } .notCurrent{ background-color:cornflowerblue; }</style> <script type="text/javascript"> //className與id的命名 關聯性 //在函數的中 數組與迴圈的使用, //需要去做項目,小模組也好。提升自己的實踐經驗。 function ShowDiv(num) { var tdArray = ["redTd", "greenTd", "blueTd"]; for (var i = 0; i < tdArray.length; i++) { document.getElementById(tdArray[i]).className = "notCurrent"; document.getElementById(tdArray[i] + "_Div").style.display = "none"; } document.getElementById(tdArray[num]).className = "current"; document.getElementById(tdArray[num] + "_Div").style.display = "block"; } </script></head><body> <table> <tr> <td id="redTd" class="current" onmouseover="ShowDiv(0)">0</td> <td id="greenTd" class="notCurrent" onmouseover="ShowDiv(1)">1</td> <td id="blueTd" class="notCurrent" onmouseover="ShowDiv(2)">2</td> </tr> </table> <div class="testDiv"><!--這個是防止整個網頁架構大動 就是這個div的大小不變化,變化的是其中的內容--> <div id="redTd_Div" class="testDiv bcgRed" style="display:block"> <!--這id的命名可謂是很巧妙呀,這都是實踐才會有的經驗--> </div> <div id="greenTd_Div" class="testDiv bcgGreen" style="display:none"> </div> <div id="blueTd_Div" class="testDiv bcgBlue" style="display:none"> </div> </div></body></html>
result:
——————————————————————————————————————————
博文的精髓,在技術部分,更在鎮場一詩。IDE: VS2015;瀏覽器: Firefox。
html+css+js,強,值得努力學習。傳智播客的視頻教程是我的學習資源,推薦。
如果博文有可以改進的地方,請留下評論,我會認真思考的。
註:我是一位正在努力的普通人,此文僅供測試與參考使用,不可做其他用途。當參考博文內容時,代表您已接受使用規定。
JavaScript基礎 選項卡效果