使用bootstrap popover,现在我试图让这个代码在popover外面点击以关闭popover:
$('body').on('click', function (e) {
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是,当我使用这个部分时,我可以关闭弹出窗口,但我不能点击其他按钮,任何人都知道我怎么能这样做?
所有按钮:
<a href="#" class="btn btn-xs btn-primary" data-toggle="popover">This opens popover</a>
<a href="#" class="btn btn-xs btn-primary">Other link</a> <- Doesn't work
<a href="#" class="btn btn-xs btn-primary">Other link</a> <- Doesn't work
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 JavaScript 函数在我的网站上获取一些 ASCII 艺术,但结果不是我现在正在寻找的......
这是它的外观:
这是我用来尝试实现这一目标的代码:
function log( text ) {
$log = $('#log');
//Add text to log
$log.append(($log.val()?"":'')+ text );
//Autoscroll
$log[0].scrollTop = $log[0].scrollHeight - $log[0].clientHeight;
}
log('<div style="font-family: monospace; white-space: pre;">' +
" _______ <br>" +
" |__ __| <br>" +
" | | ___ _ __ ___ _ __ ___ _ _ <br>" +
" | |/ _ \| '_ ` _ \| '_ ` _ \| | | |<br>" +
" | | (_) | …
Run Code Online (Sandbox Code Playgroud)我有一张表格; 我正在使用jQuery发布此表单,但现在我想知道如何在发布完成后"重置"表单?
我的jQuery和PHP代码:
<?php
chdir('../');
include("_mysql.php");
include("_settings.php");
include("_functions.php");
chdir('admin');
if (isset($_POST['rubric'])) {
if (empty($_POST['rubric']) && empty($_POST['content'])) {
echo '<div class="alert alert-error alert-box">Du måste fylla i alla fält.</div>';
}
else {
$rubric = $_POST['rubric'];
$sql = "INSERT INTO ".PREFIX."news(`date`, `poster`)
VALUES('".time()."', '".$userID."')";
mysql_query($sql);
$id = mysql_insert_id();
$sql2 = "INSERT INTO ".PREFIX."news_contents(`newsID`, `headline`, `content`)
VALUES('".$id."', '".$rubric."', '".$_POST['content']."')";
mysql_query($sql2);
echo '<div class="alert alert-box alert-success">Klart, nyheten postad.</div>';
}
}
?>
$("#form").submit(function(event) {
event.preventDefault();
var poster = $.post('addnews.php', $(this).serialize());
poster.done(function(data) {
$(".result").html(data);
});
});
Run Code Online (Sandbox Code Playgroud)
有谁知道我怎么做到这一点?因为现在当我发布一个新的量规并且内容仍然存在时,我真的不知道如何取消变量. …