将选择元素放在 javascript 提示中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8973951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Put select element in a javascript prompt?
提问by ORL
I would like to have a javascript prompt pop up that has a selection element in it rather than a text input. When searching for a solution it seems that using jquery could definitely work but I am new to HTML and javascript and the tutorials for a jquery popup are daunting (I cannot figure out how to implement them)! Is it possible to create such a pop up with just javascript? I was hoping something like this would be possible:
我想弹出一个 javascript 提示,其中包含一个选择元素而不是文本输入。在寻找解决方案时,似乎使用 jquery 肯定可以工作,但我是 HTML 和 javascript 的新手,jquery 弹出窗口的教程令人生畏(我不知道如何实现它们)!是否可以仅使用 javascript 创建这样的弹出窗口?我希望这样的事情是可能的:
prompt(<select>[options...]</select>);
Thanks in advance!
提前致谢!
回答by Diodeus - James MacFarlane
What you're looking for is called a modal dialog. This is really just a DIV with HTML inside it, with an overlay over the rest of the page.
您要查找的内容称为模态对话框。这实际上只是一个带有 HTML 的 DIV,覆盖了页面的其余部分。
You can roll-your-own or use a ready-made one from a library.
您可以自己制作或使用图书馆中现成的。
回答by Wesley
No it's not possible with prompt; If you want such thing you'll have to fake a dialog box in javascript
不,提示不可能;如果你想要这样的东西,你必须在 javascript 中伪造一个对话框