Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search anywhere in the content instead of starting

This is an example taken from MDN.

<input list="browsers" />
<datalist id="browsers">
  <option value="Chrome">
  <option value="Firefox">
  <option value="Internet Explorer">
  <option value="Opera">
  <option value="Safari">
</datalist>

Currently, When I type E in the input element, no suggestion will appear. I want to suggestions displayed if the input value element is anywhere in the option value instead of starting value.

Try It In JSBIN

Is it possible? Currently I'm using jquery Ui Autocomplete to accomplish this feature. Thanks.

like image 799
Akhil Sekharan Avatar asked Nov 02 '22 18:11

Akhil Sekharan


2 Answers

try twitter typeahead : https://github.com/twitter/typeahead.js

It works with jQuery

like image 107
isThisLove Avatar answered Nov 09 '22 16:11

isThisLove


It depends, what browser do you use. Firefox handles it as we would expect - searches within the text (tested on FF38). Chrome is limited to search from the beginning of the text (tested on Ch43).

like image 37
Jonatan Kaźmierczak Avatar answered Nov 09 '22 16:11

Jonatan Kaźmierczak