如何在警报中添加单选按钮?

时间:2014-05-27 00:02:14

标签: javascript html

所以我制作的游戏只有警报,提示和变量。如何在提示或警报中放置radiobuttons?到目前为止的进展:

alert("Welcome to...\nGRANDMA SIMULATOR 2014!\nEnjoy your stay, sweetie pie. Make yourself at home.\nCopyright (c) CookieModding. All rights served.")
var age = prompt("How old are you?")
alert("Wow! You are " + age + " already? Just yesterday it feels like I was giving you your bottle. You grow up so fast. *gives hug*")
alert("Would you like some cookies?") //I need radiobuttons that say, "YES" or "NO"

1 个答案:

答案 0 :(得分:3)

使用alert()无法做到这一点。它是窗口对象的一种方法,它不能解释HTML标记。因此,虽然您可以在字符串中添加HTML,但它不会将其呈现为html。

您需要在JavaScript中使用模式/对话框。

E.g。