我有一个问题,我想在一个警告框中输入一个输入。我要做什么来创造这个?为了做到这一点,我要添加另一个标签,属性,特殊性等...谢谢。我想可能是这样的:
<!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是一种阻塞方法(如alert)。程序执行将暂停,直到用户输入值。
只需使用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>