OK
デフォルトのandボタンの代わりに、andCANCEL
ボタンを表示SAVE
するカスタム確認ボックスをJavaScriptで作成できDELETE
ますか?
77882 次
3 に答える
15
これには、 jQueryUIダイアログボックスを使用します。
あなたはこのようなことをすることができます:
JS:
$(function() {
$("#dialog-confirm").dialog({
resizable: false,
height: "auto",
width: 400,
modal: true,
buttons: {
"Do it": function() {
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
});
});
<link href="https://jqueryui.com/jquery-wp-content/themes/jquery/css/base.css" rel="stylesheet"/>
<link href="http://jqueryui.com/jquery-wp-content/themes/jqueryui.com/style.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<div id="dialog-confirm" title="Is it treason, then?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:12px 12px 20px 0;"></span>Am I the Senate?</p>
</div>
于 2010-10-20T09:12:46.793 に答える
6
ネイティブJavaScriptの確認ボックスではありません。代わりに、モーダルダイアログをエミュレートする多くのJavaScriptUIコンポーネントの1つを使用してこれを行うことができます。
次に例を示します:https ://jqueryui.com/dialog/#modal-confirmation
私はこれを使ったことがないので、自己責任で使用してください。
于 2010-10-20T09:12:44.423 に答える
3
$('confirm text').dialog(
{
modal:true, //Not necessary but dims the page background
buttons:{
'Save':function() {
//Whatever code you want to run when the user clicks save goes here
},
'Delete':function() {
//Code for delete goes here
}
}
}
);
これは機能するはずですが、これを実行するには、jQueryおよびjQueryUIライブラリをダウンロードまたはリンクする必要があります。
于 2010-10-20T09:47:38.457 に答える