摘要:<!DOCTYPE html> <html> <head> <meta charset="uft-8"> <title>JavaScript</title> <style type="text/css"> #box{width: 
<!DOCTYPE html>
<html>
<head>
<meta charset="uft-8">
<title>JavaScript</title>
<style type="text/css">
#box{width: 100px;height: 100px;background: red;margin: 20px 80px;}
</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()">
<input type="button" value="重置" onclick="dd()">
<input type="button" value="隐藏" onclick="ee()">
<input type="button" value="显示" onclick="ff()">
<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>
</body>
</html>学习回顾了:
通过HTML元素查找
通过ID来查找:document.getElementById("id名");
改变CSS的属性
语法:document.getElementById("id").style.属性名="属性名";
函数的调用方法:
1,直接使用函数名,并且传参数给函数全局(任意地方)
2,使用window.onload=函数名(表示页面加载完成,调用该函数)这个还有点不理解。
学习了对按钮button的使用
学习回顾了自定义函数使用方法:
function 函数名(参数){
函数体
}
批改老师:灭绝师太批改时间:2018-11-11 09:33:59
老师总结:非常棒啊,知识点一目了然,继续保持!继续加油!