您的位置:首页 > Web前端 > JavaScript

javascript模拟鼠标双击事件

2014-04-25 17:59 435 查看
通常我们在做开发的时候需要通过单击切换对立事件,简单做了一个模型。

<!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>


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: