2014-08-27 52 views
1

我爲我的頁面添加了一些新功能,我正在尋找使用引導工具提示,事情是我想要一個使用html自定義工具提示,但我的代碼沒有工作。這裏是我的JavaScript:我想從引導進行默認popover

$("#container").popover({ 
    html: true, 
    title: function() { 
     return ("<div color='black'>" + title + "</div>"); 
    }, 
    trigger: 'hover', 
    content: function() { 
     return ("<div color='black'>" + text + "</div>"); 
    } 
}); 

Titletext是一些值的變量。

+0

所以你想提出工具提示或popover? :) – Kamil 2014-08-27 20:55:22

+0

對不起,一個popover,謝謝 – 2014-08-27 20:59:39

回答

0

因此,這裏是/使用 這裏的一些例子,我做的是對CSS:

<style> 
    .popover-title{ 
     background: #428bca; 
     color: #ffffff; 
    } 
</style> 

下面是HTML:

<a rel="popover" id="test" data-color="yellow" title="My Title" data-placement="top" 
           data-content="Say something!" > 

這將是JavaScript的:

$(document).ready(function() { 
    setTimeout(function(){$('#test').popover('show');},5000); 
    setTimeout(function(){$('#test').popover('hide');},15000); 
    $('body').click(function(e) { 
     $('#test').popover('hide'); 
    }); 
    $('#test2').hover(function(){ 
       if ($("#popoverTrigger").next('div.popover:visible').length){ 
        $('#test').popover('hide'); 
       }else{ 
        timer1 = setTimeout(function(){$('#test').popover('show');},900); 
        timer2 = setTimeout(function(){$('#test').popover('hide');},4800); 
        } 
       }, 
       function(){clearTimeout(timer1); clearTimeout(timer2); $('#test').popover('hide'); 
       }); 
}); 

這裏發生的事情是在我的一個divs中的某個位置出現popover。然後它在5秒後出現。 15秒後消失。如果點擊在網頁上註冊,它也會消失。還有一個懸停方法

+0

謝謝,我已經顯示popover,事情是它不顯示信息我想要的方式 – 2014-08-27 21:01:09

+0

那麼...你想如何顯示它? – Jay 2014-08-27 21:02:12

+0

我希望它有黑色字體,由於某種原因它總是白色的,如果我打開popover,我不能讀取任何東西,因爲這樣。我只想改變我的字體顏色,嘗試不同的東西,不能這樣做。 – 2014-08-27 21:04:06