如下所示:
复制代码 代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
.toopTip
{
background-color:Yellow;
border-style:solid;
border-width:1px;
border-color:Red;
}
</style>
<script language="javascript" type="text/javascript">
/*
如果希望提示的div的左边界与上边界与显示的div重叠,那么需要删除文档头W3C标准
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
*/
function initEvent() {
var divArray = document.getElementsByTagName("div");
for (var i = 0; i < divArray.length; i++) {
divArray[i].onmouseover = createDivDetailOne;
/*
无法用原始的div绑定鼠标移走的事件,因为明细的div的宽度长度都要大于原始div,
这样原始的div就被覆盖了,此时会自动触发onmouseout事件
*/
//divArray[i].onmouseout = removeDivDetail;
}
}
function createDivDetailOne() {
//保证divDetail div的唯一性
var divDetail = document.getElementById("divDetail");
if(divDetail)
{
document.body.removeChild(divDetail);
}
divObj = document.createElement("div");
divObj.className = "toopTip";
divObj.setAttribute("id", "divDetail");
divObj.style.position = "absolute";
divObj.style.width = "200px";
divObj.style.height = "100px";
var triggerObj = window.event.srcElement;
divObj.style.top = triggerObj.offsetTop;
divObj.style.left = triggerObj.offsetLeft;
divObj.innerHTML = triggerObj.innerText;
document.body.appendChild(divObj);
//此时用于明细的div已经覆盖了原div,所以覆盖的div要进行事件的处理
document.getElementById("divDetail").onmouseout = function() {
divObj = this;
if (!divObj) {
return;
}
document.body.removeChild(divObj);
};
}
function removeDivDetail() {
var divObj = document.getElementById("divDetail");
if (!divObj) {
return;
}
document.body.removeChild(divObj);
}
window.onload = initEvent;
</script>
</head>
<body>
<div id="divOne" style="background-color: Fuchsia; width: 100px; height: 100px;" >
Hello My Js World!
</div>
<div id="divTwo" style="background-color: Aqua; width: 100px; height: 100px">
Welcome to My Js World!
</div>
<div id="divThree" style="background-color: Gray; width: 100px; height: 100px">
THIS IS My Js World!
</div>
</body>
</html>
div,边距
更新日志
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]