做了个例子,希望是lz想要的效果
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>new page</title>
<script>
function m_over(obj){
var hid=document.getElementById("hid");
if(hid.value!=""){
var divObj=document.getElementById(hid.value);
document.body.removeChild(divObj);
}
var newDiv=document.createElement("div");
newDiv.id=obj.id+"_div";
hid.value=obj.id+"_div";
newDiv.innerHTML=obj.innerText+"<br>aaaaaaaa<br>bbbbbbbbb<br>cccccccccc";
newDiv.style.position="absolute";
newDiv.style.top=event.y;
newDiv.style.left=event.x;
newDiv.style.backgroundColor="#cccccc";
document.body.appendChild(newDiv);
}
</script>
</head>
<body>
<span id=s1 onmouseover="m_over(this)">标题1</span><br>
<span id=s2 onmouseover="m_over(this)">标题2</span><br>
<span id=s3 onmouseover="m_over(this)">标题3</span>
<input id=hid type=hidden value="">
</body>
</html>