Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Cycle through a list to see if there is a match for the characters entered into an input box

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.")
        }
    })
}
 
PREVIOUS NEXT
Tagged: #Cycle #list #match #characters #entered #input #box
ADD COMMENT
Topic
Name
1+5 =