选择带有1000个选项的标签-性能得到提高 [英] Select tag with 1000 options - performance hit

查看:62
本文介绍了选择带有1000个选项的标签-性能得到提高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用一个名为Chosen的插件,该插件基本上将搜索添加到选定的html对象. 我从ajax页面加载结果. 但是,我在select标签上附加了很多选项-大约一千个. 也许它是选择的插件,但是拥有1000个选项似乎有点滞后.

I am using a plugin called Chosen which basically adds searching to a select html object. I load the results from an ajax page. However I have a lot of options appended to the select tag - around a thousand. Maybe it is the chosen plugin, but having a 1000 options does seem a bit laggy.

这将如何影响性能?有哪些解决方法?

How is this gonna affect performance and what are the workarounds?

推荐答案

您可以使用<input> + <datalist>代替<select>,它可以很好地处理1000多个选项.

Instead of <select> you could use <input> + <datalist>, that handles 1000+ options pretty well.

jsfiddle

<input type="text" list="your-data-list"/>
<datalist id="your-data-list">
    <option value="1">Option 1</option>
    <option value="2">Option 2</option>
    ...
    <option value="9999">Option 9999</option>
</datalist>

这篇关于选择带有1000个选项的标签-性能得到提高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆