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

JavaScript修改元素樣式

??? 2019-01-28 14:00:49 215
????:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

</head>

<body>

<button onclick="f1(this)">變高</button>

<button onclick="f2(this)">變寬</button>

<button onclick="f3(this)">變色</button>

<button onclick="f4(this)">重置</button>

<button onclick="f5(this)">隱藏</button>

<button onclick="f6(this)">顯示</button>

<div id="box" style="width:100px;height:100px;background-color:blue;margin:50px 100px;"></div>

<script>

var btn=document.getElementById('box');

function f1(){btn.style.height="200px";    }

function f2(){btn.style.width="200px";    }

function f3(){btn.style.background="red";    }

function f4(){btn.style.height="100px";btn.style.width="100px";btn.style.background="blue";}

function f5(){btn.style.display="none";    }

function f6(){btn.style.display="block";    }

</script>

</body>

</html>

?? ???:天蓬老師?? ??:2019-01-28 14:38:53
???? ??:function f1(){btn.style.height="200px"; }如果只有一行代碼,不如直接寫到html屬性中

??? ??

?? ??