Tag: 过滤选择

通过输入框和jquery过滤选择列表

我想知道我是否可以通过jquery使用输入框过滤选择列表获得一些帮助。 这是我的js看起来像,但它似乎没有工作。 我猜这是因为选择列表中的选项不可隐藏。 $(document).ready(function() { $(“#inputFilter”).change(function() { var filter = $(this).val(); $(“#selectList option”).each(function() { var match = $(this).text().search(new RegExp(filter, “i”)); if (match > 0) { $(this).show(); // Does not work } else $(this).hide(); }); }); }); 这是我的HTML 1111 – London 1112 – Paris