[英]I want to display a message in confirm dialog in javascript without using html or any other
I want to display a message "Do you want to delete?" 我想显示一条消息“您要删除吗?” in confirm dialog.
在确认对话框中。
I had given that message in the data content, but it is not working. 我已经在数据内容中给出了该消息,但是它不起作用。
How can i do this only by using javascript ? 我如何只能通过使用javascript来做到这一点?
Here is my code : 这是我的代码:
function confirmDelete ( a )
{
$(function() {
$( "#dialog-confirm" ).dialog({
data : "Do you want to delete?",
resizable: false,
height:140,
modal: true,
buttons: {
"YES": function() {
$(this).load("./removeAgent.action?id="+a, function() {
$("#agentResult").trigger("reloadGrid");
});
$(this).dialog("close");
},
" NO ": function() {
$(this).dialog("close");
}
}
});
});
} }
You can do this by using confirm method in javascript itself. 您可以使用javascript本身中的Confirm方法来执行此操作。
The html part html部分
Click the button to display a confirm box. 单击按钮以显示一个确认框。
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
The JavaScript Part JavaScript部分
<script>
function myFunction(){
var x;
var r=confirm("Press a button!");
if (r==true){
x="You pressed OK!";
}
else{
x="You pressed Cancel!";
}
document.getElementById("demo").innerHTML=x;
}
</script>
Or 要么
If you want to use jquery plugins Lokk at the links below. 如果您想使用jquery插件,请访问下面的链接。
http://jquery-plugins.net/tag/confirm-box http://jquery-plugins.net/tag/confirm-box
http://fabien-d.github.io/alertify.js/0.4.0rc1/ http://fabien-d.github.io/alertify.js/0.4.0rc1/
Try this method in onClick listener, 在onClick侦听器中尝试此方法,
<script>
function clickAction()
{
var result;
var buttonpressed=confirm("Button Press");
if (buttonpressed==true)
{
result="OK";
}
else
{
result="Cancel";
}
document.getElementById("demo").innerHTML=result;
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.