Javascript jquery插件(即兴)
我想知道,如何在我的html中使用这个插件Javascript jquery插件(即兴),javascript,jquery,html,Javascript,Jquery,Html,我想知道,如何在我的html中使用这个插件 $.prompt("Open your javascript console to see the answer.", { title: "Are you Ready?", buttons: { "Yes, I'm Ready": true, "No, Lets Wait": false }, submit: function(e,v,m,f){ // use e.preventDefault() to prevent closing when
$.prompt("Open your javascript console to see the answer.", {
title: "Are you Ready?",
buttons: { "Yes, I'm Ready": true, "No, Lets Wait": false },
submit: function(e,v,m,f){
// use e.preventDefault() to prevent closing when needed or return false.
// e.preventDefault();
console.log("Value clicked was: "+ v);
}
});
这段代码来自我使用的是这个库,它是有用的 包括图书馆:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="http://trentrichardson.com/Impromptu/jquery-impromptu.js"></script>
CSS:
编写脚本:
<script type="text/javascript">
var multiplePromptsCounter = 1;
function openMultiplePrompts(){
$.prompt("Do you want to open another?", {
title: "A Prompt Has Opened: "+ multiplePromptsCounter++,
buttons: { "Yes, Open Another": true, "No, Close This One": false },
persistent: false,
submit: function(e,v,m,f){
if(v){
e.preventDefault();
openMultiplePrompts();
}
}
});
}
</script>
HTML:
希望它能对您有所帮助。只需在代码中包含插件,并在页面中用作警告框。当您想要显示警告时,请编写代码。我已经这样做了,但运气不佳。请发布您尝试过的内容。抱歉,我不知道如何在JSFIDDLE中包含即兴的js文件。您可以在左侧面板中包含脚本文件,在外部资源下。我可以使用提交按钮吗?我知道的不多。但是你能试试吗?
<script type="text/javascript">
var multiplePromptsCounter = 1;
function openMultiplePrompts(){
$.prompt("Do you want to open another?", {
title: "A Prompt Has Opened: "+ multiplePromptsCounter++,
buttons: { "Yes, Open Another": true, "No, Close This One": false },
persistent: false,
submit: function(e,v,m,f){
if(v){
e.preventDefault();
openMultiplePrompts();
}
}
});
}
</script>
<div class="buttons">
<button class="run" onclick="openMultiplePrompts()" >Run It!</button>
</div>