Pra*_*uel 3 html javascript jquery bootbox
单击"alert3"类的按钮时出现的提示弹出窗口不会关闭.
<a href="#" class="btn btn-primary btn-lg alert3">CLICKMEMEMEMEMEME</a>
Run Code Online (Sandbox Code Playgroud)
这是我正在调用的函数:
<script>
$(document).on("click", ".alert3", function(e) {
bootbox.prompt("What is your name?", function(result) {
if (result === null) {
Example.show("Prompt dismissed");
} else {
Example.show("Hi <b>"+result+"</b>");
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
弹出窗口没有关闭,因为你在回调函数中有一个错误,所以它在bootbox之前崩溃可以让弹出窗口消失.
最好的猜测是Example你的代码中没有定义.也许你把它放在Bootbox网站上,他们正在使用一个名为的javascript对象Example.如果要使用回调函数显示结果,可以将其添加到html中:
<a href="#" class="btn btn-primary btn-lg alert3">CLICKMEMEMEMEMEME</a><br/>
<p id='result'></p>
Run Code Online (Sandbox Code Playgroud)
然后更改您的JavaScript:
<script>
$(document).on("click", ".alert3", function(e) {
bootbox.prompt("What is your name?", function(result) {
if (result === null) {
$('#result').html("Prompt dismissed");
} else {
$('#result').html("Hi <b>"+result+"</b>");
}
});
});
</script>
Run Code Online (Sandbox Code Playgroud)