JS改变DIV样式

Original 2019-05-04 23:04:27 304
abstract:<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> #box{ height: 100px; width: 100px; b

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

<style type="text/css">

#box{

height: 100px;

width: 100px;

background-color: deeppink;

}

</style>

</head>

<body>

<div id="box">

</div>


<input type="button"  value="改变高度"onclick="aa()" />

<input type="button"  value="改变宽度"onclick="bb()"  />

<input type="button"  value="改变颜色" onclick="cc()" />


<script type="text/javascript">

var box

window.onload=function(){

box = document.getElementById("box")

}

function aa(){

box.style.height = "400px"

}

function bb(){

box.style.width= "400px"

}

function cc(){

box.style.backgroundColor = "blue"

}

</script>


</body>

</html>


Correcting teacher:查无此人Correction time:2019-05-05 09:09:26
Teacher's summary:完成的不错。js比较难,因为它的功能非常强大。继续加油。 js每行语句最后增加;号。

Release Notes

Popular Entries