I am trying to make tooltips on the left side of the cursor instead of the right side using a jquery plugin called EasyTooltip.
I am trying to give a negative value in a header call, the purpose of which will affect the positioning on the x axis, but without effects (nothing appears, while a positive value on both axes should work fine):
<script type="text/javascript">
$(document).ready(function() {
$(".middle img").easyTooltip({
tooltipId: "easyTooltip2",
xOffset: -300,
yOffset: 50
});
});
</script>
I am new to javascript and I think I would have to hack the script, but I need your advice here. This is the script:
(function($) {
$.fn.easyTooltip = function(options){
var defaults = {
xOffset: 10,
yOffset: 20,
tooltipId: "easyTooltip",
clickRemove: false,
content: "",
useElement: ""
};
var options = $.extend(defaults, options);
var content;
this.each(function() {
var title = $(this).attr("title");
$(this).hover(function(e){
content = (options.content != "") ? options.content : title;
content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
$(this).attr("title","");
if (content != "" && content != undefined){
$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");
$("#" + options.tooltipId)
.css("position","absolute")
.css("top",(e.pageY - options.yOffset) + "px")
.css("left",(e.pageX + options.xOffset) + "px")
.css("display","none")
.fadeIn("fast")
}
},
function(){
$("#" + options.tooltipId).remove();
$(this).attr("title",title);
});
$(this).mousemove(function(e){
$("#" + options.tooltipId)
.css("top",(e.pageY - options.yOffset) + "px")
.css("left",(e.pageX + options.xOffset) + "px")
});
if(options.clickRemove){
$(this).mousedown(function(e){
$("#" + options.tooltipId).remove();
$(this).attr("title",title);
});
}
});
};
})(jQuery);
Thanks so much for any input. Cheers
source
share