我使用过相同的 jQuery 插件,但它给我带来了一些问题,即同一页面上的大量元素。在测试了一些之后,我选择了这个:
你可以在这里看到一个工作 演示!
和网页链接 在这里!
已编辑
根据评论的要求,这里有一个基于上述插件的 jQuery 扩展:
查询
(function($) {
  $.fn.tooltipImg = function(options) {
    // options    
    var opts = $.extend({}, $.fn.tooltipImg.defaults, options);
    // when the mouse gets over the element
    $(this).hover(function(e){
      this.t = this.alt;
      var c   = (this.t != "") ? "<br/>" + this.t : "",
          src = ($(this).data("src")!='') ? $(this).data("src") : this.src,
          res = '<p class="'+opts.wrapper+'"><img src="'+src+'" alt="Image preview" />'+c+'<p>';
      $("body").append(res);
      $("."+opts.wrapper)
        .css({
          "top"  : (e.pageY - opts.xOffset) + "px",
          "left" : (e.pageX + opts.yOffset) + "px"
        })
        .fadeIn("fast");                      
      },
      function(){
        $("."+opts.wrapper).remove();
      });
      // when the mouse moves while over the element
      $(this).mousemove(function(e){
        $("."+opts.wrapper)
          .css({
            "top"  : (e.pageY - opts.xOffset) + "px",
            "left" : (e.pageX + opts.yOffset) + "px"
          });
      });
  }
  // options defaults
  $.fn.tooltipImg.defaults = {
    xOffset : 10,
    yOffset : 30,
    wrapper : 'myTooltipImgWindow'
  }
})(jQuery);
用法
$(document).ready(function(){
  $('.tooltipMe').tooltipImg();
  // with options
  $('.tooltipMe').tooltipImg({
    xOffset : 20,
    yOffset : 40,
    wrapper : 'myToolTipContainerClass'
  });
});
你可以看到这个工作的小提琴!
这个小提琴说明了来自跨域的图像,具有相对路径和来自img src.
请注意,Fiddle 下的相对路径是错误的,有时您会看到它,有时您不会,但它工作得很好!