같은 jQuery를에 플러그인하지만 같은 페이지에 나에게 요소의 많은 양의 몇 가지 문제가 주어졌다 . 일부 테스트 후, 나는이 일에 대한 거부했습니다
이
당신은 작업demo here!
그리고 웹 페이지 링크
편집Here!
을 볼 수 있습니다 요청으로 주석에는 위의 플러그인을 기반으로하는 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);
USAGE
$(document).ready(function(){
$('.tooltipMe').tooltipImg();
// with options
$('.tooltipMe').tooltipImg({
xOffset : 20,
yOffset : 40,
wrapper : 'myToolTipContainerClass'
});
});
이 working Fiddle!
이 바이올린은 상대 경로와 img
src
에서 크로스 도메인에서 이미지를 보여 볼 수 있습니다.
피들 (Fiddle)의 상대 경로는 버그 번호가 일 때가 있습니다. 가끔씩 보지만, 그렇지 않은 경우도 있지만 잘 작동합니다!
어떤 플러그인을 사용하고 있습니까? –
@RicardoLohmann http://jquery.bassistance.de/tooltip/demo/ –
코드를 보여줄 수 있습니까? –