📜  循环浏览列表以查看输入框中输入的字符是否匹配 - Javascript代码示例

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

代码示例1
const menu_items = document.querySelectorAll('li');

function getInputValue() {
    // Selecting the input element and get its value 
    var inputVal = document.getElementById("myInput").value;
    menu_items.forEach(item => {
        if (item.textContent.includes(inputVal)) {
            console.log(inputVal + " is in the list.")
        }
    })
}