2016-06-09 60 views
0

從不同鏈接打開彈出窗口時出現問題。bootstrap popover僅從一個鏈接打開

這裏我javascript代碼:

<a href="#" id="popover" data-type="1">Link 1</a> 
<a href="#" id="popover" data-type="2">Link 2</a> 

酥料餅的內容:

<div id="content" class="hidden"> 
    Contents 
</div> 
<div id="title" class="hidden"> 
    Title 
</div> 

$("#popover").popover({ 
    html : true, 
    content: function() { 
     var type = $(this).data("type"); 
     alert(type); 
     return $("#content").html(); 
    }, 
    title: function() { 
     return $("#title").html(); 
    } 
}); 

,以便從他們打開酥料餅在這裏,我的兩個鏈接

我有這個問題:我只能從LINK 1打開彈出窗口,當我點擊LINK 2時什麼也沒有發生。

+0

不知道這將是問題的原因,但有些事我注意到的是,標識必須是唯一的。 – NTL

回答

1
$(".popover").popover({ 
    html : true, 
    content: function() { 
     var type = $(this).data("type"); 
     alert(type); 
     return $("#content").html(); 
    }, 
    title: function() { 
     return $("#title").html(); 
    } 
}); 


<a href="#" class="popover" data-type="1">Link 1</a> 
<a href="#" class="popover" data-type="2">Link 2</a> 

不正確的重複ID HTML標籤

+0

謝謝,解決了這個問題! –