您必须创建custome confirmBox ,无法更改确认功能显示的对话框中的按钮 .
Jquery confirmBox
是 span>
否 span>
DIV>
函数doConfirm(msg,yesFn,noFn)
{
var confirmBox = $(“#confirmBox”);
. confirmBox.find( “消息”)文本(MSG);
confirmBox.find( “是的, . 没有”) . 取消绑定() . 点击(函数()
{
confirmBox.hide();
});
confirmBox.find( “是” . )点击(yesFn) .
confirmBox.find( “不” . )点击(noFn) .
confirmBox.show();
}
通过您的代码调用它:
doConfirm(“你确定吗?”,函数yes()
{
form.submit();
,函数号()
{
// 没做什么
});
**纯JavaScript confirmBox **
Yes
No
submit
Script :
function doSomething(){
document.getElementById('id_confrmdiv').style.display="block"; //this is the replace of this line
document.getElementById('id_truebtn').onclick = function(){
//do your delete operation
alert('true');
};
document.getElementById('id_falsebtn').onclick = function(){
alert('false');
return false;
};
}
CSS :
body { font-family: sans-serif; }
#id_confrmdiv
{
display: none;
background-color: #eee;
border-radius: 5px;
border: 1px solid #aaa;
position: fixed;
width: 300px;
left: 50%;
margin-left: -150px;
padding: 6px 8px 8px;
box-sizing: border-box;
text-align: center;
}
#id_confrmdiv button {
background-color: #ccc;
display: inline-block;
border-radius: 3px;
border: 1px solid #aaa;
padding: 2px;
text-align: center;
width: 80px;
cursor: pointer;
}
#id_confrmdiv .button:hover
{
background-color: #ddd;
}
#confirmBox .message
{
text-align: left;
margin-bottom: 8px;
}