After watching a tutorial on using Javascript with Autocomplete and a JSON file, I implemented the code successfully. However, I encountered an issue:
- When I clear the input field, all results from the file are displayed. I've tried adding code to clear the results, but it doesn't seem to work as intended.
The demo on JSFiddle isn't functioning properly for me due to restrictions on adding assets. Here's the section of the code that should be handling the clearing of data when the input box is empty:
if (matches.length === 0) {
matchList.innerHTML = ''; // Line 31: The results aren't cleared when the input is empty.
}
In the CSS field, I included some hardcoded data from the JSON file for your reference.
Appreciate any help, Matthttps://i.stack.imgur.com/f8FiS.jpg