如何在“确定”后单击警告框中引发事件 [英] how to raise an event after 'ok' click in alert box
本文介绍了如何在“确定”后单击警告框中引发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在'确定'后点击警告框中的事件?
不确认我需要提醒
解决方案
只需在调用alert
函数后输入代码:
alert(' 这里的文字');
// 您在此处输入的代码将在用户在警告框中单击确定后执行
或者,如果你想要一个包含Yes和No选项的盒子,那么使用确认
功能:
if (确认(' 这里的文字')){
// 用户点击是
}
其他 {
// 用户点击否
}
function myFunction()
{
var x;
var r = confirm( 按a !按钮跨度>);
if (r == true )
{
x = < span class =code-string> 你按OK!;
}
其他
{
x = < span class =code-string>你按下取消!;
}
document .getElementById( 演示跨度>)的innerHTML = X。;
}
---------
HTML
---------
< 按钮 onclick = myFunction() > 按我< span class =code-keyword>< / button >
< p id = demo > < / p >
alert('EnterBook代码');
how to raise an event after 'ok' click in an alert box ?
not confirm i need alert
解决方案
Just put your code after you call thealert
function:
alert('Your text here'); // the code that you put here will be executed after the user clicks OK in the alert box
Or, if you mean that you want a box with Yes and No options, then use theconfirm
function:
if (confirm('Your text here')) { // user clicked on Yes } else { // user clicked on No }
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; }
---------
HTML
---------
<button onclick="myFunction()">Press Me</button> <p id="demo"></p>
alert('EnterBookCode');
这篇关于如何在“确定”后单击警告框中引发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文