It adds every time that you move the cursor in the autocomplete menu more and more spaces in the class name attribute Basically this is the solution: Change all the 'selected' texts to ' selected' (a space after the first quote). I attach the file with the modification [auto-complete.js.zip](https://github.com/Pixabay/JavaScript-autoComplete/files/1693522/auto-complete.js.zip) and the diff. [auto-complete.js.diff.zip](https://github.com/Pixabay/JavaScript-autoComplete/files/1693525/auto-complete.js.diff.zip)