更新一下js$(function(){
var x = 10;
var y = 20;
$(".tooltip").each(function(){
this.onmousemove=function(e){
e=event || window.event; 
alert("进入onmouseover方法");
var div="<div id='tip'>"+this.title+"</div>";
this.title="";
$("body").append(div);
$("#tip").css({
"top":(e.clientX+x)+"px",
"left":(y)+"px",
"position":"absolute",
"border":"1px solid #CCC",
"color":"red"
}).show();

alert("当前元素X:"+$(this).offset().top+"Y坐标:"+$(this).offset().left+"<br/>"+"当前div坐标X:"+document.getElementById("tip").style.top+"Y坐标:"+document.getElementById("tip").style.left);

};

$(this).onmousemout=function(e){
e=event || window.event; 
alert("mouseout方法");
$("#tip").remove();
};


});
});为什么这个不支持onmouseover呢    onmouseout也没执行 而却这个生成的tip位置也不对

解决方案 »

  1.   

     this.onmousemove=function   - > this.onmouseover=function   
    ..拼写错误
      

  2.   

    事件都响应了,坐标问题还得在看<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"type="text/javascript"></script>
    <script type="text/javascript">
    $(function(){
    var x = 10;
    var y = 20;
    $(".tooltip").each(function(){
    this.onmouseover=function(e){
    e=event || window.event;
    //alert("进入onmouseover方法");
    var div="<div id='tip'>"+$(this).attr('title')+"</div>";

    $("body").append(div);
    $("#tip").css({
    "top":(e.clientX+x)+"px",
    "left":(y)+"px",
    "position":"absolute",
    "border":"1px solid #CCC",
    "color":"red"
    }).show();

    //alert("当前元素X:"+$(this).offset().top+"Y坐标:"+$(this).offset().left+"<br/>"+"当前div坐标X:"+document.getElementById("tip").style.top+"Y坐标:"+document.getElementById("tip").style.left);

    };

    this.onmouseout=function(e){
    e=event || window.event;
    //alert("mouseout方法");
    $("#tip").remove();
    };


    });
    });
    </script>
    </head>
    <body>

    <table>
    <tr>
    <td style="text-align:center;" class="tooltip" title="这是我的jquery超链接提示">试试看 tip好用不</td>
    </tr>
    </table>
    </body>
    </html>
      

  3.   

    "top":(e.clientX+x)+"px", ???
    top 表示上沿位置,应该是 y 坐标
    同理,letf 得用 x 坐标计算