有没有办法让选择下拉列表的第一个字母自动完成,而不是在 jQuery 上,而是在 PURE JavaScript 上?像[唯一的例子!!!]:
<input type="text" onkeyup="autoComplete();" />
<select id="mySelectDropdwonList">
<option>John</option>
<option>Michael</option>
<option>Toml</option>
</select>
<script type="text/javascript">
function autoComplete() {
// what is the code ??
}
</script>
Run Code Online (Sandbox Code Playgroud)
它应该像链接http://harvesthq.github.io/chosen/的 jQuery 解决方案一样工作,但在纯 JS 上
仅在 HTML5 中的解决方案:
<input type="text" list="mySelectDropdwonList" />
<datalist id="mySelectDropdwonList">
<option>John</option>
<option>Michael</option>
<option>Toml</option>
</datalist>Run Code Online (Sandbox Code Playgroud)