[英]In Javascript how can I change an alert window to display that alert next to an input box
[英]How can I put an input in the alert() box?
我有一个问题,我想在警告框中输入一个输入。 我必须做什么才能创建这个? 为此,我必须添加另一个标签、属性、特殊属性等……谢谢。 我想可能是这样的:
<!DOCTYPE html> <html> <head> <title>example</title> </head> <body> <script type="text/javascript"> alert("<input></input>"); </script> </body> </html>
您可以使用
var resp = window.prompt("Your question")
window.prompt 是一种阻塞方法(如警报)。 程序执行将停止,直到用户输入一个值。
只需使用var value = prompt('Your Question');
这段代码被执行:
<!DOCTYPE html> <html> <body> <h2>JavaScript Confirm Box</h2> <button onclick="myFunction()">Try it</button> <input id="demo" /> <script> function myFunction() { var txt; if (confirm("Press a button!")) { txt = "You pressed OK!"; } else { txt = "You pressed Cancel!"; } document.getElementById("demo").innerHTML = txt; console.log(txt); } </script> </body> </html>
window对象自带三种显示用户对话框的方法
此方法将停止当前正在执行的程序,直到用户对此框提供任何响应
window.prompt(text, defaultText)
这将从用户那里获取价值以进行进一步的处理
window.alert(message)
这只会提醒用户他的行为。
window.confirm(message)
这将采用布尔形式的用户响应进行进一步处理
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.