可编辑组合框Javascript和HTML [英] Editable Combo Box Javascript and HTML
本文介绍了可编辑组合框Javascript和HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要做以下事情:
使用 JavaScript , HTML输入标记具有文本类型和选择标记(组合框),创建一个可编辑的组合框。
我不知道如何使组合框可编辑。你可以给我一些建议吗?
我这样创建组合框,但显然不可编辑:
< HTML>
< label>您的首选编程语言:< / label>
< select id =combobox>
< option value =>选择一个...< / option>
< option value =ActionScript> ActionScript< / option>
< option value =AppleScript> AppleScript< / option>
< / select>
< / html>
我应该在哪里使用输入标记?
datalist 元素! :) pre class =snippet-code-html lang-html prettyprint-override>
< html> < label>您的首选编程语言:< / label> < input type =textlist =combo-optionsid =combobox> < datalist id =combo-options> < option value =ActionScript> ActionScript< / option> < option value =AppleScript> AppleScript< / option> < / datalist>< / html>
I need to do the following thing: Using JavaScript, the HTML input tag having the text type and a select tag (combo box), create an editable combo box.
I have no idea how to make a combo box editable. Can you give me some suggestions, please?
I create the combo box like this, but is obviously not editable:
<html>
<label>Your preferred programming language: </label>
<select id="combobox">
<option value="">Select one...</option>
<option value="ActionScript">ActionScript</option>
<option value="AppleScript">AppleScript</option>
</select>
</html>
Where should I use the input tag?
解决方案
HTML5 includes the datalist
element which solves this problem! :)
<html>
<label>Your preferred programming language: </label>
<input type="text" list="combo-options" id="combobox">
<datalist id="combo-options">
<option value="ActionScript">ActionScript</option>
<option value="AppleScript">AppleScript</option>
</datalist>
</html>
这篇关于可编辑组合框Javascript和HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文