一个小小小栗子
昨天朋友圈一篇"不要跟北邮人谈恋爱"突然火了,里面有个小姑娘的男朋友给写了一个exe,下面评论一片叫大神的。。就一脸黑人问号??于是我也写了一个,虽然没有女朋友可以送,心疼自己哈哈。
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style type="text/css" >
#div1{
height:50px;
width:100px;
background-color:red;
}
#div2{
height:50px;
width:100px;
background-color:blue;
}
</style>
</head>
<body>
<div>
<div id="div1">呵呵</div>
<div id="div2">hhh</div>
</div>
</body>
<script type="text/javascript">
window.onload = function(){
document.getElementById("div1").addEventListener("mouseover",function(){
this.style.position = 'absolute';
this.style.top = Math.round(Math.random()*500)+'px';
this.style.left = Math.round(Math.random()*500)+'px';
});
document.getElementById("div2").onclick = function(){
alert("呵呵");
}
};
</script>
</html>