数组排序

mouse down-up

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 100px;
				height: 100px;
				background-color: black;
			}
		</style>
	</head>
	<body>
		<div id="div1" onmousedown="zoomout()" onmouseup="zoomin()"></div>
	</body>
	<script type="text/javascript">
		function zoomout(){
			var div1=document.getElementById("div1");
			div1.style.width="200px";
			div1.style.height="200px";
			div1.style.backgroundColor="yellowgreen";	
		}
		function zoomin(){
			var div1=document.getElementById("div1");
			div1.style.width="100px";
			div1.style.height="100px";
			div1.style.backgroundColor="black";	
		}
	</script>
</html>

onclick

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p id="p1" onclick="fun()">单击事件测试</p>
	</body>
	<script type="text/javascript">
		function fun(){
			//获取指定的元素
			var p1=document.getElementById("p1");
			p1.innerText="我被单杀了!"
			p1.style.fontSize="60px";
		}
	</script>
</html>

ondblclick

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 100px;
				height: 100px;
				background-color: skyblue;
			}
		</style>
	</head>
	<body>
		<div id="div1" onclick="zoomout()" ondblclick="zoomin()"></div>
	</body>
	<script type="text/javascript">
		function zoomout(){
			var div1=document.getElementById("div1");
			div1.style.width="200px";
			div1.style.height="200px";
			div1.style.backgroundColor="red"
		}
		function zoomin(){
			var div1=document.getElementById("div1");
			div1.style.width="100px";
			div1.style.height="100px";
			div1.style.backgroundColor="skyblue";
		}
	</script>
</html>

onmouse enter-leave

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#div1{
				width: 100px;
				height: 100px;
				background-color: black;
			}
		</style>
	</head>
	<body>
		<div id="div1" onmouseenter="zoomout()" onmouseleave="zoomin()" onmousedown="zoomon()"></div>
	</body>
	<script type="text/javascript">
		function zoomout(){
			var div1=document.getElementById("div1");
			div1.style.width="200px";
			div1.style.height="200px";
			div1.style.backgroundColor="red";	
		}
		function zoomin(){
			var div1=document.getElementById("div1");
			div1.style.width="100px";
			div1.style.height="100px";
			div1.style.backgroundColor="skyblue";	
		}
		function zoomon(){
			var div1=document.getElementById("div1");
			div1.style.width="200px";
			div1.style.height="200px";
			div1.style.backgroundColor="black";	
		}
	</script>
</html>

数组排序

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var classScore = [82, 56, 87, 96, 85, 74, 23, 56, 59, 85, 78, 74, 29, 98, 100, 46, 42, 85, 69];
			var small = classScore.sort(function(m, n) {
				return m - n;
			});//xxx[5]
			alert(small[0]);//最小值
			alert(small[small.length-1]);//最大值
			
			var sum=classScore.reduce(Arr);
			function Arr(m,n){
				return m+n;
			}
			var avg = sum/classScore.length;
			alert(avg);//平均值
			
			var sum1=0;
			for(i=0;i<classScore.length;i++){
				sum1+=(avg-classScore[i])*(avg-classScore[i])
			}
			over=sum1/classScore.length;
			alert(Math.sqrt(over));//标准差
			//4
			// var small=classScore.reverse();
			// alert(small);
			//3
			//var small=classScore.sort(function(m.n));
			//renturn m-n;
			// alert(small);
			//2
			//var small=classScore.sort();
			// alert(small);
			//1
			// var abc=["ant","Ant","block","count","documens","1689"]
			// alert(abc.sort());
		</script>
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值