<head>
<script language="javascript" type="text/javascript">function show(e,val){
if(val!=null){
document.getElementById('sp').style.display="none";
}else{
var x,y,z;
x=e.clientX;
y=e.clientY;
document.getElementById('sp').style.left=x+"px";
document.getElementById('sp').style.top=y+"px";
document.getElementById('sp').style.display="block";
}
}
</script>
</head>
<body>
<div style="width:400px;height:300px;background-color:pink;text-align:center;"  onmousemove="show(event)"  >
<span style="font-size:50px;color:green" onmouseover="show(event,this)">欢迎光临</span>
</div>
<span id="sp" style="position:absolute;top:0px;left:0px;color:#FF00A0;display:none">点击线路查看</span>
</body>

解决方案 »

  1.   


    <head>
    <script language="javascript" type="text/javascript">function show(e,val){
    if(val!=null){
    document.getElementById('sp').style.display="none";
    }else{
    var x,y,z;
    x=e.clientX;
    y=e.clientY;
    document.getElementById('sp').style.left=x+"px";
    document.getElementById('sp').style.top=y+"px";
    document.getElementById('sp').style.display="block";
    }
    }
    function hide() {
    document.getElementById('sp').style.display="none";
    }
    </script>
    </head>
    <body>
    <div style="width:400px;height:300px;background-color:pink;text-align:center;" onmousemove="show(event)"  onmouseout="hide();">
    <span style="font-size:50px;color:green" onmouseover="show(event,this)">欢迎光临</span>
    </div>
    <span id="sp" style="position:absolute;top:0px;left:0px;color:#FF00A0;display:none">点击线路查看</span>
    </body>
      

  2.   

     我测试过了还是不行 能再想想嘛 当鼠标移动到span元素时文字提示就消失 我在想是不是当鼠标移动到span上时执行了onmouseover()后立即执行了onmousemove()所以会出现文字提示还在的现象 谢啦 帮忙在想想 急!!!