js 模拟事件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>12313</title>
</head>
<body>
<div class="wrapper" id="wrapper">
<ul>
<li class="aa">12313</li>
<li class="aa">12313</li>
<li class="aa">12313</li>
<li class="aa">12313</li>
</ul>
</div>
<script type="text/javascript">
window.onload = function(){
var a = {
id:function(id){
return document.getElementById(id)
},
dom:function(dom,parent){
var parent = parent || document;
return parent.getElementsByTagName(dom);
},
getStyle:function(obj,attr){
return obj.currentStyle?obj.currentStyle[attr]:getComputedStyle(obj,false)[attr];
}
}
a.id("wrapper").onmouseout = function(e){
alert("af")
}
var event;
if(a.id("wrapper").currentStyle){
event = document.createEventObject();
event.screenX=0;
event.screenY=0;
event.clientX=0;
event.clientY=0;
event.ctrlKey = false;
event.altKey = false;
event.shiftKey = false;
event.button = 0;
a.id("wrapper").fireEvent("onmouseout",event)
}else{
event = document.createEvent("MouseEvents");
event.initMouseEvent("click",true,true,document.defaultView,0,0,0,0,0,false,false,false,false,0,null);
a.id("wrapper").dispatchEvent(event);
}
}
</script>
</body>
</html>