【发布时间】:2021-12-28 01:56:35
【问题描述】:
我使用一些引导元素为我的按钮设置了一些属性,但是当我第一次单击该按钮时它不起作用。我需要单击按钮外的某处,然后再次单击该按钮。
我已经通过在 onload 中调用函数并在按钮中再次调用它来解决这个问题,但是现在我无法再这样做了,所以我想知道是否有其他方法可以解决这个问题?
这是我的代码: https://jsfiddle.net/a22177861/x381z0h6/6/
HTML:
<button type="button" class="btn btn-warning" onclick="PopOver(this,'Hi','Thank','You');">ClickMe!</button>
JS:
function PopOver(myObj, mgr, Adate, Vdate) {
$(function () {
myObj.setAttribute("data-container", "body");
myObj.setAttribute("data-toggle", "popover");
myObj.setAttribute("data-placement", "bottom");
myObj.setAttribute("data-html", "true");
myObj.setAttribute("data-trigger", "focus");
myObj.setAttribute("title", "otherInfo");
myObj.setAttribute('data-content', "MGR:"+mgr+"<br />DATE1:"+Adate+"<br />DATE2:"+Vdate);
$("[data-toggle='popover']").popover();
});
}
任何帮助将不胜感激!
【问题讨论】: