jquery鼠标放上去显示悬浮层即弹出定位的div层
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:functionshow(obj,id){varobjDiv=$("#"+id+"");$(objDiv).css("di...
复制代码 代码如下:
<script language="javascript" src="jquery-1.4.2.min.js"></script>
<script>
function show(obj,id) {
var objDiv = $("#"+id+"");
$(objDiv).css("display","block");
$(objDiv).css("left", event.clientX);
$(objDiv).css("top", event.clientY + 10);
}
function hide(obj,id) {
var objDiv = $("#"+id+"");
$(objDiv).css("display", "none");
}
</script>
<>
<div id="mydiv1">
提示1效果
</div>
<div id="mydiv2">
提示2效果
</div>
<a id="t1" onMouseOver="javascript:show(this,'mydiv1');" onMouseOut="hide(this,'mydiv1')">鼠标放上去1</a>
<br><br><br><br><br>
<a id="t2" onMouseOver="javascript:show(this,'mydiv2');" onMouseOut="hide(this,'mydiv2')">鼠标放上去2</a>