Javascript 将按钮插入Popover不起作用
我正在尝试将2个按钮插入由触发的popover。清除历史记录按钮:Javascript 将按钮插入Popover不起作用,javascript,jquery,twitter-bootstrap,bootstrap-4,bootstrap-modal,Javascript,Jquery,Twitter Bootstrap,Bootstrap 4,Bootstrap Modal,我正在尝试将2个按钮插入由触发的popover。清除历史记录按钮: <div class="modal-footer text-nowrap"> <button type="button" class="clear-history btn btn-link">Clear history</button> </div> 清晰的历史 const clearHistoryBtn=` 所有记录将被删除 对 不 `; $('.clear hi
<div class="modal-footer text-nowrap">
<button type="button" class="clear-history btn btn-link">Clear history</button>
</div>
清晰的历史
const clearHistoryBtn=`
所有记录将被删除
对
不
`;
$('.clear history').popover({
位置:'底部',
是的,
标题:“你正在清理历史”,
内容:clearHistoryBtn
});
但只有popover中的文本:
我不知道这是否与模态有关
更新:
我的内容的其余部分到哪里去了???
我没有将任何css(如display:none或.hide()或visibility:hidden或removeClass()等)设置为您可以通过这种方式执行的任何按钮,工作示例如下:
const clearHistoryBtn=`
所有记录将被删除
对
不
`;
$('.clear history').popover({
位置:'底部',
是的,
标题:“你正在清理历史”,
内容:clearHistoryBtn
});代码>
清晰的历史
我能在这把小提琴中让它工作-。也许有一些JS/CSS在干扰?你的控制台有错误吗?@Jon Lambson我们的唯一区别是我把它放在页脚,而你把它放在页脚body@Jon兰布森和我在比赛中没有任何失误console@Jon兰布森,请检查我的更新!看看这个链接:它不工作。我看不到按钮,因此警报不会弹出,但它在这里工作,您可以通过点击运行代码片段来检查相同的情况。如果它在您的代码中不起作用,那么它可能在您的代码中存在脚本顺序问题或任何其他css、脚本冲突问题。你可以分享你得到的错误或者脚本的顺序。没有错误。此脚本位于带$(document).readyok的libs src之后。这背后的唯一原因是其他css干扰引导和更改popover的UI。您是否可以对其他css或自定义css进行注释,以查看输出或找出原因。
const clearHistoryBtn = `
<span>All records will be removed</span>
<button type="button" class="confirm-clear-history btn btn-sm btn-danger">Yes</button>
<button type="button" class="btn btn-sm btn-link">No</button>
`;
$('.clear-history').popover({
placement: 'bottom',
html: true,
title: 'You are cleaning the history',
content: clearHistoryBtn
});