Use HTML5 (datalist) autocomplete with 'contains' approach, not just 'starts with'

前端 未结 4 734
清歌不尽
清歌不尽 2020-11-29 05:03

(I can\'t find it, but then again I don\'t really know how to search for it.)

I want to use and

4条回答
  •  清歌不尽
    2020-11-29 05:58

    yet this thread is posted about 2 years ago. but if you are reading this thread, you maybe need to check a newer version of your browser:

    Current specification: https://html.spec.whatwg.org/multipage/forms.html#the-list-attribute

    User agents are encouraged to filter the suggestions represented by the suggestions source element when the number of suggestions is large, including only the most relevant ones (e.g. based on the user's input so far). No precise threshold is defined, but capping the list at four to seven values is reasonable. If filtering based on the user's input, user agents should use substring matching against both the suggestions' label and value.

    And when this post written, behavior of Firefox (51) and Chrome (56) had already been changed to match the specification.

    which means what op want should just work now.

提交回复
热议问题