使用警报框要求用户输入 [英] Ask for user input using alert box
本文介绍了使用警报框要求用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望用户在警报框中输入一段文字.
I want the user to input a piece of text in an alert box.
HTML:
<form>
<select class="favoritefood">
<optgroup label="Dairy products">
<option>Cheese</option>
<option>Egg</option>
<option id="newDairy">NEW</option>
</optgroup>
<optgroup label="Vegetables">
<option>Cabbage</option>
<option>Lettuce</option>
<option>Beans</option>
<option>Onions</option>
<option>Courgettes</option>
<option id="newVeg">NEW</option>
</optgroup>
</select>
</form>
JS:
$('.favoritefood').change(function () {
var id = $(this).find('option:selected').attr('id');
if (id == 'newDairy') {
alert("input");
};
});
我知道可以在警报框中输入内容,但是怎么办?
I know it is possible to have an input inside the alert box, but how?
推荐答案
这将是提示框
var result = prompt('type something');
这篇关于使用警报框要求用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文