Setting up a Framework to build Google's Autocomplete

Let's set the template as a framework to begin building Google's Autocomplete Functionality.

We'll cover the following

The document structure #

Let’s layout the minimum amount of HTML needed to have something to work with as we build out the functionality. Remember, we’re focusing on JavaScript first for this component.

The search component looks like it can be split up into three main sub-components:

  • The search bar where the input and icon are
  • The autocomplete results
  • The buttons

The search bar will consist of the input element and something (maybe a div, maybe a button) for the microphone icon (whatever it does isn’t within the scope of this project, but we’ll account for its presence nonetheless).

The autocomplete results look like it can just contain an unordered list as the sole element. Unordered in this case means that HT​ML’s ul, as opposed to ol – ordered list. The name shouldn’t be taken too seriously. Its meaning is closer to un-numbered-by-default. The buttons are just two buttons, as pointed out in the scoping phase. We’ll have to anticipate that it’ll need to blend in with the autocomplete results when they show up. We should be able to manipulate it as required with JavaScript.

The HTML #

Let’s write some code.

Get hands-on with 1400+ tech skills courses.