摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>js 与 div</title> &n
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>js 与 div</title>
<style type="text/css">
#test{margin:0px 0px;width:200px;height:200px;background:#ccc;border:1px solid #ff00ff;}
</style>
</head>
<body>
<div id = "test"></div>
<div style="margin:5px auto;">
<input type="button" name="button1" value="边框变粗" onclick="changetest()"/>
<input type="button" name="button1" value="边角变圆" onclick="changeradius()"/>
<input type="button" name="button1" value="重置" onclick="changereset()"/>
<input type="button" name="button1" value="隐藏" onclick="changehidden()"/>
<input type="button" name="button1" value="显示" onclick="changedisplay()"/>
</div>
<script type="text/javascript">
var test;
window.onload=function(){ //window.onload是在页面加载完成后执行
test=document.getElementById("test")
}
function changetest(){
test.style.border="4px solid #000000"
}
function changeradius(){
test.style.borderRadius="10px"
}
function changereset(){
test.style.border="1px solid #ff00ff";
test.style.borderRadius="0px"
}
function changehidden(){
test.style.display="none";
}
function changedisplay(){
test.style.display="block";
}
//关于数组
////数组的创建
var a = new Array();
a[0] = 1;
a[1] = 2;
a[2] = 3;
document.write(a +'<br>');
document.write(a[0]);
//创建二维数组
var two = new Array(
new Array(90,91),
new Array(93,96));
document.write(two[0][0]);
//将数组转化成字符串
var txt=Array(1,2,3,4);
document.write('<br>');
document.write(typeof(txt) +'<br>');
txt2 = txt.join();
document.write(typeof(txt2) +'<br>');
//数组排序
txt3 = txt.reverse();
console.log(txt3);
var x=3,y=6;
z=x+y;
n=100;
document.write(z+'<br/>')
document.write(x*y+'<br/>')
document.write((x+=y)+'<br/>')
document.write((x-=y)+'<br/>');
document.write('测试if语句-----'+"<br/>")
if(n>50) document.write("N大于50" +'<br/>');
if(n>=100)
{document.write("优秀");}
else if(n>90)
{document.write("良好");}
else{document.write("及格");}
document.write("<br>")
//输出1-100整数中能被3整除的数字
//运用for循环
for (i=1,n=0;i<=100;i++){
if(i%3==0){
document.write(i +' ');
n++;
if(n%3==0){
document.write('<br>');
}
}
}
//总共有多少个数
document.write("总共有"+ n +"个数");
document.write('<br>');
//switch多重分支表达式
var job = 3;
switch(job){
case 1:doaument.write("试用期员工");
break;
case 2:document.write('实习员工');
break;
case 3:document.write("正式员工");
break;
default:document.write("临时工")
break;
}
//3.字符串长度
var txt="hello world";
document.write(txt.length + "<br/>");
document.write(txt.charAt(1));
var txt="数字世界";
txt2 = txt.concat(x);
document.write(txt2);
</script>
</body>
</html>
批改老师:灭绝师太批改时间:2018-11-16 09:11:31
老师总结:测试的比较认真,非常棒,希望要都要记住奥!继续保持!