http://blog.csdn.net/veeasy/article/details/42527301
// Add tooltip for product gallery var h2TitleObj = $('.node-type-structure-product h2'), productImageGalleryTop = $('.product-gallery').offset().top, productImageGalleryLeft = $('.product-gallery').offset().left; //console.log(typeof productImageGallery.offset().top); //console.log(typeof productImageGallery.offset().left); $.each(h2TitleObj, function (key, value) { if (this.innerHTML.trim() == "Images") { //$(this).addClass('tooltip-active').attr('tooltip-attr','Click to see large image'); /* $(this).tooltip({ show: { effect: "blind", duration: 800 }, content: "Click to see large image", }); */ $(this).attr('tooltip-attr','Click to see large image').tooltip({ //show: { effect: "blind", duration: 800 }, content: "Click to see large image", items: "[tooltip-attr]", position: { //my: "left top", //at: "right center", collision: "none", //of: ".product-gallery", //within: ".product-gallery",}, using: function () { $(this).css({top: productImageGalleryTop+"px", left: productImageGalleryLeft+"px"}); }, }, }); $(this).tooltip("open"); } });