0
其实我想从HTML按钮标签中定义的onclick属性中调用一个函数,它是一个jQuery的弹出函数。我无法成功。如何从HTML的onclick属性调用jQuery自定义函数?
我的脚本是:
<script type="text/javascript">
$(document).ready(function() {
$('#popoverId').popover({
html: true,
title: 'Popover Title <a class="close" href="#");">×</a>',
content: '<div class="msg">Your Text Here</div>',
});
$('#popoverId').click(function (e) {
e.stopPropagation();
});
$(document).click(function (e) {
if (($('.popover').has(e.target).length == 0) || $(e.target).is('.close')) {
$('#popoverId').popover('hide');
}
});
});
</script>
我想通过HTML点击数事件来运行该代码
我的HTML代码:
<input type="submit" id="popoverId" class="btn btn-large btn-danger" onclick="myfunction()" />
其实我想要显示的酥料饼的时候我点击该按钮,但不是从按钮ID。我想在JavaScript的onclick事件中调用该函数时显示弹出窗口。
你可以尝试手动触发。但也需要附加在选择器上。 –