Home>Article>Web Front-end> How to implement the fast search function of js
This article mainly introduces how to implement the fast search function of js. It has certain reference value. Now I share it with you. Friends in need can refer to it.
The company's projects are very tight these days. Then there were all kinds of messy things, and suddenly I wanted to have the entire search function. The first thing I thought of was fuzzy search using PHP, but it consumes a lot of performance, and the speed of retrieving data is extremely slow. On Baidu I found a function to search through js and shared it with everyone.
This is the page
js code{eq name="list['state']" value='0'}
- 请添加菜品类型
{else} {eq name="list['count']" value='0'}- 请添加菜品
{else} {volist name="list['data']" id='list'}- {$list.food_name}{$list.food_code}
{/volist} {/eq} {/eq}
1 $("#foodCode").keyup(function(){ 2 $("#foodList ul li").stop().hide().filter(":contains('"+($(this).val())+"')").show();//contains 匹配文本中内容 3 });php only outputs data, so it will not be released here The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website! Related recommendations:
How to get the value of the scroll bar by encapsulating scroll.js
How to solve the problem of for in object in Vue Problems with attributes that are non-negative integers
Parsing of built-in objects in js
The above is the detailed content of How to implement the fast search function of js. For more information, please follow other related articles on the PHP Chinese website!