2011-07-30 74 views
1

嗨,我使用qTip 2我想要類ui-tooltip-dark ui-tooltip-shadow,但它不顯示該類。我有這樣的代碼:jQuery qTip不改變類?

$('.selector').qtip({ 
    content: { 
     text: function(api) { 
     // Retrieve content from custom attribute of the $('.selector') elements. 
     return $(this).attr('qtip-content'); 
     } 
     }, 
     title: { 
     text: function(api) { 
      // Retrieve content from ALT attribute of the $('.selector') element 
      return $(this).attr('alt'); 
     } 
     }, 
    style: { 
     classes: 'ui-tooltip-dark ui-tooltip-shadow'; 
     } 
}); 

但是當我把那就是在其網站上它的工作原理

u能告訴我的代碼我要去哪裏錯了?

編輯

<script type="text/javascript" class="example"> 
$(document).ready(function() 
{ 
    $('.selector').qtip({ 
    content: { 
     text: function(api) { 
     // Retrieve content from custom attribute of the $('.selector') elements. 
     return $(this).attr('qtip-content'); 
     } 
    }, 
     title: { 
     text: function(api) { 
      // Retrieve content from ALT attribute of the $('.selector') element 
      return $(this).attr('alt'); 
     } 
     }, 
    style: { 
     classes: 'ui-tooltip-dark ui-tooltip-shadow'; 
     } 
}); 
}); 
</script> 
+0

請張貼從你說的是工作演示網站的代碼。如果演示中的代碼正在爲你工作,那就用它吧? – Sparky

+0

我修改了它,得到這個,但是它不能正常工作 – kritya

+0

這是我最後一次問這個問題:**請發佈代碼,以便爲你工作**。你說過,「當我把他們的網站上的代碼運行時」_。所以只要在你修改它之前告訴我們什麼「有效」。 – Sparky

回答

1

它可能就是你已經張貼什麼錯字,但你錯過了周圍的內容部分花括號 -

$('.selector').qtip({ 
    content: { 
     text: function(api) { 
     // Retrieve content from custom attribute of the $('.selector') elements. 
     return $(this).attr('qtip-content'); 
     } 
    }, 
     title: { 
     text: function(api) { 
      // Retrieve content from ALT attribute of the $('.selector') element 
      return $(this).attr('alt'); 
     } 
     }, 
    style: { 
     classes: 'ui-tooltip-dark ui-tooltip-shadow'; 
     } 
}); 

編輯

試試這個 -

$(document).ready(function() 
{ 
    $('.selector').qtip({ 
    content: { 
     text: function(api) { 
     // Retrieve content from custom attribute of the $('.selector') elements. 
     return $(this).attr('qtip-content'); 
     }, 
     title: { 
     text: function(api) { 
      // Retrieve content from ALT attribute of the $('.selector') element 
      return $(this).attr('alt'); 
     } 
     } 
    }, 
    style: { 
     classes: 'ui-tooltip-dark ui-tooltip-shadow' 
     }  
    }); 
}); 

你應該能夠看到它在這裏工作 - http://jsfiddle.net/KaJ9q/

+0

沒有,仍然沒有工作:/ – kritya

+0

我把放置什麼ü張貼退房後放置編輯 – kritya

+0

你可以發佈一個鏈接到qtip網站上的代碼,你說的作品? – ipr101