I created tooltips to substitute the default browser "TITLE" bubble. I've read a lot of threads and all of them suggests I should remove title
temporarily on mouseover
and put it back on later. I am trying to do exacly that, but I am failing to. Here is my code and the reason why I use jQuery live
is because I want the effect to apply to dynamically added elements later:
tooltip : {
activate : function(selector){
$(selector).each(function(){
$(selector).live('mouseover',function(e){
tooltip.init(this,true,e);
});
$(selector).live('mouseout',function(e){
tooltip.init(this,false,e);
});
});
},
init : function(elem,show,e){
var title = $(elem).attr('title');
this.addTip(elem,show,title);
...
},
addTip : function(elem,show,title) {
var code = '<div class="tooltip-wrapper">'+title+'</div>';
if(show) {
$(elem).after(code);
setTimeout('$(".tooltip-wrapper").fadeIn("slow")',500);
}
else {
$(".tooltip-wrapper").remove();
}
}
}
I call this script like this:
tooltip.activate(selector);
Another problem I have is that it gives me HIERARCHY_REQUEST_ERR: DOM Exception 3
error if I try this tooltip.activate("*");
, but it works if I use input
as a selector.
Any input will be much appreciated :-)