2016-06-09 79 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

谢谢,解决了这个问题! –