【发布时间】:2019-08-17 03:48:34
【问题描述】:
我有一个 Bootstrap 4.3.1 弹出框,内容中嵌入了一个表格。一切都显示了,但表格没有。在下面的代码中,我尝试了content 的函数以及直接$('#a02').html() 的函数。
$("[data-toggle=popover]").popover({
html: true,
content: function() { return $('#a02').html(); }, // Also tried directly without function
title: 'Test'
}).click(function() {
$(this).popover('show');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/js/bootstrap.bundle.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<a href="#" data-toggle="popover" data-trigger="focus" data-placement="right">
Click Here for Popover
</a>
<div id="a02" style="display: none;">
Some text before table
<div>
<table width="100%">
<thead>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</thead>
<tbody>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
</div>
有些人尝试向我展示一个适用于 Bootstrap 3 的 JSFiddle。我拿走了他们的 JSFiddle,只是将 Bootstrap refs 更改为 4,它就坏了。 Bootstrap 3 JSFiddle | Bootstrap 4 JSFiddle
【问题讨论】:
标签: jquery twitter-bootstrap popover