亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Js控制DIV的作業(yè)

??? 2019-01-04 23:38:53 199
????:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <style> #box{ width: 200px; height: 200px; backgrou
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#box{
width: 200px;
height: 200px;
background: pink;
}
</style>
</head>
<body>
<!-- <div id="div" onclick="ccc(this)">

</div> -->
<div id="box">
<!--  <input type="button" value="變寬" onclick="kuan()"> -->
</div>
<input type="button" value="變寬" onclick="kuan()">
<input type="button" value="變高" onclick="gao()">
<input type="button" value="重置" onclick="cz()">
<input type="button" value="變圓" onclick="yuan()">
<input type="button" value="隨機(jī)變色" onclick="bs()">
<script>
// function person(){
//  this.name='lisi';y
//  this.age='25';
//  this.sex='男';
//  this.say=function (){
//  return "hi,my name is"+this.name+"the year is"+this.age+"i am a"+this.sex+"nice to meet you";
//  }
// }
// var ls=new person();
// alert(ls.say());
// var d=new Date();
// var week=["星期一","星期二","星期三","星期四","星期五","星期六","星期天"];
// document.write(week[0]);

// document.write("今天是"+week[d.getDay()]);
// var di=document.getElementById("div");
// di.style.cssText='width:600;height:600;background:pink';
// di.style.width="600px";
// di.style.height="600px";
// di.style.background="pink";
// function ccc(){
//  var di=document.getElementById("div");
//  di.style.cssText='width:300px;height:300px;background:pink';
// }
var bi;
window.onload=function(){
bi=document.getElementById("box");
}
function kuan(){
bi.style.width="600px" //第一種控制CSS寫法
}
function gao(){
bi.style.cssText="height:600px"//第二種用cssText控制寫法
}
function yuan(){
bi.style.borderRadius="300px"
//bi.style.cssText="border-radius:300px;"
}
function cz(){
bi.style.cssText="width:200px;height:200px;"
}
function bs(){
// function rgb(){
//  var r=Math.floor(Math.random()*256);
//  var g=Math.floor(Math.random()*256);
//  var b=Math.floor(Math.random()*256);
//  var rgb='('r','g','b')'
//  return rgb;
// }

//  var ArrayCl=new Array("olive","teal","red","blue","maroon","navy","lime","fuschia","green","purple","gray","yellow","aqua","white","silver");
//  var n=0;

//  if(n<(ArrayCl.length-1)&&n>=0){
//  // document.background = ArrayCl[n];
// n=0;n++;
// }
function rcl(){
var r,g,b;
r=Math.floor(Math.random()*256);//Math.floor用來取整,Math.random--取0-1之間的隨機(jī)數(shù)
g=Math.floor(Math.random()*256);
b=Math.floor(Math.random()*256);
return "rgb("+r+','+g+','+b+")"
}
bi.style.background = rcl();
}

</script>

</body>
</html>


?? ???:韋小寶?? ??:2019-01-05 09:07:55
???? ??:JavaScript的功能還是很強(qiáng)大的!輕輕松松的控制一些dom的樣式,對dom的內(nèi)容進(jìn)行操作等!課后要多練習(xí)哦!

??? ??

?? ??