鼠标事件
html原码
<p id="p1">点我试试</p>
<p id="p2" class="xia">我出来了</p>
获取元素
var ns = document.getElementById('p1');
var nx = document.getElementById('p2');;
一、点击
鼠标点击onclick
ns.onclick = function(){
nx.style.display = 'block';
}
二、双击
鼠标双击onDblclick
ns.onDblclick = function(){
nx.style.display = 'block';
}
三、鼠标移动
鼠标移动onmousemove
ns.onmousemove = function(){
nx.style.display = 'block';
}
四、鼠标移出
鼠标移出onmouseout
ns.onmouseout = function(){
nx.style.display = 'block';
}
五、鼠标移入
鼠标移入onMouseOver
ns.onmousemove = function(){
nx.style.display = 'block';
}
六、鼠标右键
鼠标移入onMouseDown
ns.onMouseDown= function(){
nx.style.display = 'block';
}