Skip to content

Can you set the text of an autocomplete?

Let’s say i have an element like the foregoing:

<input id="userName">

Is it possible to set an autocomplete string and then do:

document.getElementById('userName').autocomplete = true;


It is not possible directly, but there is a hack for that… like this:

   <input list="autocomplete_list" name="my_input" />
   <datalist id="autocomplete_list">
       <option value="hello">
       <option value="hi">
       <option value="what's up">
   <input type="submit">