改变DIV样式

Original 2018-11-27 00:43:21 269
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>改变DIV样式</title><style type="text/css">#div1{height: 200px;width: 200px;background:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>改变DIV样式</title>
<style type="text/css">
#div1{height: 200px;width: 200px;background: red;margin: 20px 50px;}
</style>
</head>
<body>
<div id="div1"></div>
<input type="button" value="变高" onclick="aa()">
<input type="button" value="变宽" onclick="bb()">
<input type="button" value="变色" onclick="cc()">
<input type="button" value="重置" onclick="dd()">
<input type="button" value="隐藏" onclick="ee()">
<input type="button" value="显示" onclick="ff()">
<script type="text/javascript">
var div1
window.onload=function () {
div1=document.getElementById('div1');
}
function aa() {
    div1.style.height="450px";
}
function bb() {
div1.style.width="400px";
}
function cc() {
div1.style.background="#ccc";

}
function dd() {
div1.style.height="200px";
div1.style.width="200px";
div1.style.background="red";
}
function ee() {
div1.style.display="none";
}
function ff() {
div1.style.display="block";
}
</script>

</body>
</html>


Correcting teacher:韦小宝Correction time:2018-11-27 09:02:32
Teacher's summary:嗯!写的很不错!课后别忘了要多多练习哦!

Release Notes

Popular Entries