亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript案例及總結(jié)

asal 2018-12-07 20:48:04 255
abstrak:<!DOCTYPE html> <html > <head>          <meta charset="UTF-8">        &
<!DOCTYPE html>
<html >
<head>
         <meta charset="UTF-8">
         <title>changeDIV</title>
    <style style="text/css">
                #box{height: 100px;width: 100px;background-color: red;margin:20px 90px;}     
    </style>
</head>
<body>
         <script style="text/javascript">
                  var box
        window.onload=function(){
                box=document.getElementById("box")
        }
        function heighten(){
                box.style.height="400px"//變高
        }
        function widen(){
                box.style.width="400px"//變高
        }
        function discolor(){
                box.style.backgroundColor="pink"//變色
        }
        function reset(){
                box.style.height="100px"
                box.style.width="100px"
                box.style.backgroundColor="red"
        }
        function hide(){
                box.style.display="none"//顯示
        }
        function show(){
                box.style.display="block"//隱藏
        }
         </script>
         <div id="box"></div>
         <input type="button" value="變寬" onclick="heighten()">
         <input type="button" value="變高" onclick="widen()">
         <input type="button" value="變色" onclick="discolor()">
         <input type="button" value="重置" onclick="reset()">
         <input type="button" value="隱藏" onclick="hide()">
         <input type="button" value="顯示" onclick="show()">
    總結(jié):
    選擇器的使用
    全局變量的定義:window.load()
    HTML DOM 改變css樣式:語(yǔ)法document.getElementById().style.屬性="屬性值"
    屬性帶 - 的 使用駝峰寫(xiě)法
    display屬性的使用
    onclick事件
    問(wèn)題:
    document.getElementById() 括號(hào)內(nèi)部 老師講課的時(shí)候有時(shí)單引號(hào),又時(shí)雙引號(hào),但并不影響結(jié)果,
    我想問(wèn)的是 是不是可以隨便用,還有給數(shù)組元素賦值的時(shí)候也是這樣
</body>
</html>


Guru membetulkan:天蓬老師Masa pembetulan:2018-12-07 23:33:12
Rumusan guru:將大量的事件寫(xiě)到標(biāo)簽中,不是一個(gè)好方案, 不過(guò)現(xiàn)階段是可行的

Nota Keluaran

Penyertaan Popular