如何从提示窗口获取响应并使其显示在网页上的某个位置?
我现在的代码是:
<html>
<head>
<center>
<FORM>
<INPUT type="button" value="Click Me." name="button" onClick="alert('I Like Waffles')">
<INPUT type="button" value="Whats Your Favorite Food" name="button" onClick="prompt('Whats Your Favorite Food?')">
</FORM>
</center>
</head>
</html>
我想知道如何从提示中获取响应并将其放置在 html 中的某个位置。
最佳答案
提示将返回值。
alert(prompt('Whats Your Favorite Food?'))
<html>
<head>
<center>
<FORM>
<INPUT type="button" value="Click Me." name="button" onClick="alert('I Like Waffles')">
<INPUT type="button" value="Whats Your Favorite Food" name="button" onClick="alert(prompt('Whats Your Favorite Food?'))">
</FORM>
</center>
</head>
</html>
关于javascript - 我如何获得提示的响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31364673/