简体   繁体   English

jQuery工具提示在IE中不起作用

[英]jQuery tooltip not working in IE

I am using the jquery tooltip and here is the code for it 我正在使用jquery工具提示,这是它的代码

Javascript : Javascript

this.tooltip = function()
{   
    var xOffset = -10;
    var yOffset = -175;     

    $("a.tooltip").hover(function(e)
    {                                             
        this.t = this.title;
        this.title = "";
        var breakdownData = "";
        var header = "<b>This document contains:</b><br />";

        switch(this.id)
        {
            case '_ctl0_MasterContentPlaceHolder_hpl_DownloadCCPS1':
                breakdownData = "<div style='padding-left:30px;'><br /></div>";
                break;
            case '_ctl0_MasterContentPlaceHolder_hpl_DownloadCCPS2':
                breakdownData = "<div style='padding-left:30px;'></div>";
                break;
            case '_ctl0_MasterContentPlaceHolder_hpl_DownloadCCPS3':
                breakdownData = "<div style='padding-left:30px;'></div>";
                break;
            case '_ctl0_MasterContentPlaceHolder_hpl_DownloadCCPS4':
                breakdownData = "<div style='padding-left:30px;'></div>";
                break;
        }   

        $("body").append("<div id='tooltip' style='width:350px; padding-left:15px; font-size:11px;'>"+ header + breakdownData +"</div>");
        $("#tooltip").css("top",(e.pageY - xOffset) + "px")
                     .css("left",(e.pageX + yOffset) + "px")
                     .fadeIn("fast");       
        }, function() {
            this.title = this.t;
            $("#tooltip").remove();
        }); 

        $("a.tooltip").mousemove(function(e) {
            $("#tooltip").css("top",(e.pageY - xOffset) + "px")
                         .css("left",(e.pageX + yOffset) + "px");
        });         
    };
}

$(document).ready(setTimeout("tooltip()", 500));            

CSS : CSS

 #tooltip
 {
     position:absolute;
     border:1px solid #333;
     background:#f7f5d1;
     padding:2px 5px;
     color:#333;
     display:none;
     width:350px;
 }

All I need to do is add the tooltip class to the anchor tag which works fine in Firefox but not in IE. 我需要做的就是将工具提示类添加到锚标记中,该标记在Firefox中可以正常工作,但在IE中则不能。 Has anyone else experienced this? 其他人有没有经历过?

Here is a link to the original which seems to work just fine http://cssglobe.com/lab/tooltip/01/ 这是原始文件的链接,看起来似乎很好http://cssglobe.com/lab/tooltip/01/

Thank You 谢谢

I was able to test it fine in both FF3, IE6, and IE7. 我能够在FF3,IE6和IE7中对其进行良好的测试。 What problems are you experiencing? 您遇到什么问题?

I did receive one bug in Firebug however: 我确实在Firebug中收到一个错误:

fn.call is not a function jquery-1.2.6.js Line 2295
    jQuery.readyList.push( function() { return fn.call(this, jQuery); } );

Which led me to change your $(document).ready function to: 这导致我将您的$(document).ready函数更改为:

$(document).ready(function(){
    setTimeout("tooltip()", 500)
});

Not sure if that will solve your problem, but give it a try. 不知道这是否可以解决您的问题,请尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM