当我在按钮元素上单击两次(不是双击,只是在任何时间点单击两次)时,我试图让这个函数运行一次,然后初始化它,然后将其重置。
<a href="#" onclick="popHover()">
$('.challenge_popover').popover()
var clicked = false
function popHover() {
// I NEED THIS PART TO RUN ON THE FIRST CLICK
if (clicked == false)
{
$('.challenge_popover').popover('destroy')
}
// AND THIS PART TO RUN ON THE SECOND CLICK
$(document).live('mousedown', function(e) {
if (e.which == 1)
{
$('.challenge_popover').popover()
clicked = true
}
});
}