【发布时间】:2020-11-30 21:45:57
【问题描述】:
使用 Bootstrap 4,我设置了一个弹出框来显示一些 HTML 内容。在弹出框内,我想使用 jQuery 显示/隐藏带有其他内容的 div,但我无法让它显示隐藏的内容。
HTML
<div class="text-center">
<button id="show-popover" type="button" class="btn btn-primary mt-5" data-toggle="popover">Click Me</button>
</div>
<!-- popover content -->
<div id="popover-content" class="d-none">
<div class="card border-0">
<div class="card-body">
<a href="#" id="show-div">Show more content</a>
<div id="hidden-content" class="d-none">
div with more content...
</div>
</div>
</div>
</div>
jQuery
$(function () {
$('#show-popover').popover({
container: 'body',
html: true,
placement: 'bottom',
sanitize: false,
content: function() {
return $('#popover-content').html();
}
})
});
$('#show-div').click(function(){
$('#hidden-content').toggle();
});
【问题讨论】:
标签: jquery twitter-bootstrap bootstrap-popover