2011-12-29 62 views
1

我敢肯定,这是一个简单的问题..我已经浪费了太多的时间已经在它jQuery的提示,使HREF标题消失

我有如下形象:

<img src="/_/img/icons/103-map.png" alt="Find Me" title="come and find me..." class="action findMe_map"/> 

而下面JavaScript的使用jQuery的1.2.6工具:

<script> 
    $(document).ready(function() { 

    // create custom animation algorithm for jQuery called "bouncy" 
    $.easing.bouncy = function (x, t, b, c, d) { 
     var s = 1.70158; 
     if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
     return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
    } 

    // create custom tooltip effect for jQuery Tooltip 
    $.tools.tooltip.addEffect("bouncy", 

     // opening animation 
     function(done) { 
      this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
     }, 

     // closing animation 
     function(done) { 
      this.getTip().animate({top: '-=15'}, 500, 'bouncy', function() { 
       $(this).hide(); 
       done.call(); 
      }); 
     } 
    ); 

    $('img.findMe_map').click(function() { 
     event.preventDefault(); 
     console.log(this); 
     $('img[title]').tooltip({effect: 'bouncy'}); 
    }); 
</script> 
  • 当我使用上面的代码,标题由消失输出和工具提示不显示我想这个问题解决

  • 当我注释掉click()的提示行,单击图像,“来找我......”出现在安慰。

困惑。

+2

由于浏览器经常会将'title'属性显示为工具提示,因此大多数工具提示插件会移除'title'属性以防止两者一次弹出。 – Blazemonger 2011-12-29 13:30:20

回答

2

说明

当您初始化它时,所有工具提示选项都可以进行配置。

$("#demo img[title]").tooltip({ 
    effect: 'bouncy', 
    tipClass: 'foo', 
    ... 
}); 

事件不会按照您习惯的方式进行控制。
在初始化工具提示他们实际上配置:

$("#demo img[title]").tooltip({ 
    effect: 'bouncy', 
    events:{...} 
}); 

你可以阅读更多关于它here

我猜你想让它在你点击它时反弹,就像它那样here


解决方案

Here's a working solution on JSFiddle与您如何使用事件3个不同的例子。
..虽然它看起来不像它们在他们的网站上那么酷,但它展示了它的工作原理!

// create custom animation algorithm for jQuery called "bouncy" 
$.easing.bouncy = function (x, t, b, c, d) { 
    var s = 1.70158; 
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
} 

// create custom tooltip effect for jQuery Tooltip 
$.tools.tooltip.addEffect("bouncy", 

    // opening animation 
    function(done) { 
     this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show(); 
    }, 

    // closing animation 
    function(done) { 
     this.getTip().animate({top: '-=15'}, 500, 'bouncy', function() { 
      $(this).hide(); 
      done.call(); 
     }); 
    } 
); 

//Manage all the settings here, and only do it once 
$("img.findMe_map").tooltip({ 
    effect: 'bouncy', 
    events: { 
     def: "click, mouseout", // default show/hide events for an element 
    } 
}); 

文档

所有的文档都可以找到here

快乐编码! :)

+0

欢呼声。漂亮的图片......感谢您的详细回复! – sdolgy 2011-12-29 23:07:51

+0

@sdolgy谢谢,我尽量在回答时尽可能详尽,因此提问者和其他可能会遇到同样问题的人会更容易。我喜欢抽象艺术:3 – ShadowScripter 2011-12-29 23:22:46