📜  选择选项过滤器 javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:20.645000             🧑  作者: Mango

代码示例1
function filter() {
        var keyword = document.getElementById("search").value;
        var select = document.getElementById("select");
        for (var i = 0; i < select.length; i++) {
            var txt = select.options[i].text;
            if (!txt.match(keyword)) {
                $(select.options[i]).attr('disabled', 'disabled').hide();
            } else {
                $(select.options[i]).removeAttr('disabled').show();
            }

        }
    }