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

通過js來改變CSS樣式

原創(chuàng) 2019-04-08 15:22:43 211
摘要:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>js來改變一下樣式</title><style type="text/css">.box{width: 100px;height: 100px;background

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>js來改變一下樣式</title>

<style type="text/css">

.box{width: 100px;height: 100px;background: red;margin-bottom:20px ;}

.boxx{width: 100px;height: 300px;background: red; }

.boxxx{width: 300px;height: 300px;background: blue; }

</style>

</head>

<body>

<div></div>

<input type="button" value="變高" onclick="bg(this)">

<input type="button" value="變寬" onclick="bk(this)">

<input type="button" value="變色" onclick="bs(this)">

<input type="button" value="重置" onclick="cz(this)">

<input type="button" value="隱藏" onclick="yc(this)">

<input type="button" value="顯示" onclick="xs(this)">



<script type="text/javascript">

var box=document.getElementsByClassName('box')[0]

var box1=document.getElementsByTagName('div')[0]

function bg(num) {

box.className="boxx"

}

function bk(num) {

box.style.cssText="width: 200px;"

}

function bs(num) {

box1.style.background="blue"

}

function cz(num) {

box1.style.cssText="width: 100px;height: 100px;background: red;margin-bottom:20px ;"

}

function yc(num) {

box.style.display="none"

}

function xs(num) {

box.style.display="block"

}


</script>

</body>

</html>


批改老師:查無此人批改時間:2019-04-08 16:04:39
老師總結(jié):完成的不錯。每行js代碼,后面增加;號。繼續(xù)加油

發(fā)佈手記

熱門詞條