您可以通过这种方式进行操作,下面给出的工作示例:
我正在尝试将2个按钮插入由.clear-history按钮触发的弹出窗口:
<div class="modal-footer text-nowrap">
<button type="button" class="clear-history btn btn-link">Clear history</button>
</div>
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
});
但是在弹出框内只有文本:
更新:
我内容的其余部分去哪儿了???我没有将任何display,none,.hide()或可见性:hidden或removeClass()等CSS设置为任何按钮
我正在尝试将2个按钮插入弹出式窗口,该按钮由.clear-history按钮触发:
您可以通过这种方式进行操作,下面给出的工作示例:
const clearHistoryBtn = ` <span>All records will be removed</span> <button type="button" class="confirm-clear-history btn btn-sm btn-danger" onclick="alert('event raised from yes button');">Yes</button> <button type="button" class="btn btn-sm btn-link" onclick="alert('event raised from no button');">No</button> `; $('.clear-history').popover({ placement: 'bottom', html: true, title: 'You are cleaning the history', content: clearHistoryBtn });
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> <div class="modal-footer text-nowrap"> <button type="button" class="clear-history btn btn-link">Clear history</button> </div>
您可以通过这种方式进行操作,下面给出的工作示例: