Blogger Information
Blog 250
fans 3
comment 0
visits 322884
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js-双按钮点名器
梁凯达的博客
Original
921 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div id="div"></div>
	<button onclick="go()">开始</button>
	<button onclick="stop()">停止</button>
</body>
<script>
	//名称数组
		var nameList =['凤凤','如花','芙蓉姐姐','石榴姐姐','麻老湿','小泽老湿','苍老湿','琦琦老湿','泷老湿'];

		var div = document.getElementById('div');

		var timmer;

	//点击go让我们的名字动起来
	function go(){
		console.log(timmer);
		//判断我们是否是第一次点击操作
		if(timmer == undefined){
			timmer =setInterval(function(){
				//随机数组下标
				var  num = Math.floor(Math.random()*nameList.length);
				div.innerHTML = nameList[num];
			},1);
		}
	}
	//让我们的名字停止
	function stop(){
		//alert(2);
		//清除定时器
		clearInterval(timmer);
		timmer = undefined;
	}

</script>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post