[英]How to add multiple data-content in jQuery popup?
I want my popover to show multiple data-content, ie 3 different lines of text inside the popover. 我希望我的popover显示多个数据内容,即popover中的3个不同的文本行。 I have the following code, referred from w3schols.
我有以下代码,来自w3schols。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h3>Popover Example</h3>
<a href="#" data-toggle="popover" title="Popover Header" data-placement="bottom" data-content="Info 1">Toggle popover</a>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
</script>
</body>
</html>
The popover looks like this. popover看起来像这样。
I want the popover to show three more options like "Info 1", "Info 2" and "Info 3" like a list view. 我希望popover显示另外三个选项,如“Info 1”,“Info 2”和“Info 3”,如列表视图。 How can I achieve this?
我怎样才能做到这一点?
Try: 尝试:
Demo; 演示; http://jsfiddle.net/jo6og612/
http://jsfiddle.net/jo6og612/
1)Define div with html which you want to show in popover 1)使用要在popover中显示的html定义div
<div class="container">
<h3>Popover Example</h3>
<a href="#" data-toggle="popover" title="Popover Header" data-placement="bottom">Toggle popover</a>
<div id="popover-content">
<ul>
<li> Info 1 </li>
<li> Info 2 </li>
<li> Info 3 </li>
</ul>
</div>
</div>
2) Add content and html properties of popover 2)添加popover的内容和html属性
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover(
html: true,
content: function() {
return $('#popover-content').html();
}
);
});
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.