tooltip jQuery non funziona in IE
-
07-07-2019 - |
Domanda
Sto usando il tooltip jquery ed ecco il codice per esso
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 :
#tooltip
{
position:absolute;
border:1px solid #333;
background:#f7f5d1;
padding:2px 5px;
color:#333;
display:none;
width:350px;
}
Tutto quello che devo fare è aggiungere la classe tooltip al tag anchor che funziona bene in Firefox ma non in IE. Qualcun altro ha provato questo?
Ecco un link all'originale che sembra funzionare bene http://cssglobe.com / lab / tooltip / 01 /
Grazie
Soluzione
Sono stato in grado di testarlo bene in FF3, IE6 e IE7. Quali problemi stai riscontrando?
Tuttavia, ho ricevuto un bug in Firebug:
fn.call is not a function jquery-1.2.6.js Line 2295 jQuery.readyList.push( function() { return fn.call(this, jQuery); } );
Che mi ha portato a cambiare la tua funzione $ (documento). già in:
$(document).ready(function(){ setTimeout("tooltip()", 500) });
Non sono sicuro se questo risolverà il tuo problema, ma provalo.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow