5

Is there any way to show all options of datalist on focus? I need to show all the options even after a key press.

<form action="" method="get">
 <input list="browsers" name="browser">
 <datalist id="browsers">
  <option value="Internet Explorer">
  <option value="Firefox">
  <option value="Chrome">
  <option value="Opera">
  <option value="Safari">
 </datalist>
 <input type="submit">
</form>

FIDDLE

PS: This is not same as this question. My datalist options are generated dynamically using jquery.

Community
  • 1
  • 1
Fasna
  • 564
  • 1
  • 10
  • 28
  • Possible duplicate of [Editable 'Select' element](http://stackoverflow.com/questions/2141357/editable-select-element) – jhamon Jan 17 '16 at 13:51
  • 2
    Use a javascript select script instead. datalist filters based on input by default – charlietfl Jan 17 '16 at 14:13
  • select script? Is it a library or what? – Fasna Jan 17 '16 at 14:27
  • 1
    A similar question was later answered here: [How can I make a browser display all datalist options when a default value is set?](http://stackoverflow.com/questions/37478727/how-can-i-make-a-browser-display-all-datalist-options-when-a-default-value-is-se) – Icarus Dec 15 '16 at 17:49
  • Just a word of caution the datalist element is not widely supported across all browsers. [http://caniuse.com/#search=datalist](http://caniuse.com/#search=datalist) – Nick Clark May 15 '17 at 18:08
  • Just FYI, if you want to implement searchable input field there's a lot of jquery plugin for it. ex. https://select2.github.io or https://harvesthq.github.io/chosen/ – morgan9999 May 19 '17 at 13:11
  • they answered on it here : https://stackoverflow.com/a/42187207/1919821 It help me – pery mimon Sep 13 '17 at 21:56

1 Answers1

-2
$('input').on('click', function() {
  $(this).val('');
});

try this this will work