摘要:<!DOCTYPE html> <html> <head> <title> 改变DIV </title> <style type="text/css"> #box{width: 100px;height: 100px;background: r
<!DOCTYPE html>
<html>
<head>
<title>
改变DIV
</title>
<style type="text/css">
#box{width: 100px;height: 100px;background: red;margin: 20px 80px;}
</style>
<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.background="pink" //改变颜色
}
function dd() {
box.style.height="100px" //重置
box.style.width="100px"
box.style.background="red"
}
function ee() {
box.style.display="none" //隐藏
}
function ff() {
box.style.display="block" //显示
}
</script>
</head>
<body>
<div id="box"></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()">
</body>
</html>用了三天时间,做了6次,今天代码终于实现功能了。又认真看了几次的代码,发现也没有问题啊,都是一样的,为啥就不成功呢?难道是因为今天换了一台电脑。。。。。。。
JS快学完了,但是好象学会了,又好象什么都没有学会。每次看到代码都能看懂,但是自己写起的时候,不看笔记就不会写了。还是没有完全吃透啊。
批改老师:天蓬老师批改时间:2018-12-17 15:44:38
老师总结:有这么复杂吗? 为了实现一个功能, 还换了一台电脑, 只想问一声: 兄弟, 肾, 还好吗?