javascript模拟鼠标双击事件

通常我们在做开发的时候需要通过单击切换对立事件,简单做了一个模型。

<!DOCTYPE html>
<html>
<head>
	<title>javascript</title>
	<meta charset="utf-8">
	<style type="text/css">
	#box{
		height: 200px;
		line-height: 200px;
		text-align: center;
		background: #eeeeee;
	}
	</style>
</head>
<body>
	<div id="box">
		单击鼠标显示边框
	</div>
<script type="text/javascript">
	var box = document.getElementById('box');
	var flog = true;
	box.onclick = function(){
		if(flog){
			box.style.border = "3px solid #000000";
			box.innerHTML = "单击鼠标隐藏边框";
			flog = false;
		}else{
			box.style.border = "0px";
			box.innerHTML = "单击鼠标显示边框"
			flog = true;
		}
	}
</script>
</body>
</html>

  

posted @ 2014-04-25 17:59  陈朔  阅读(3818)  评论(1编辑  收藏  举报