2011-12-29 61 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