The company these days the project is very tense, and then always have a variety of things, suddenly said to the entire search function, the first time to think of is the use of PHP fuzzy search, but the sexual energy consumption is very large, and the speed of the data to be removed slowly, Baidu found a search by JS to share the function to everyone.
This is the page
Out after the effect:
Page code:
1 <Divstyle= "border:1px solid #ccc; margin:20px;padding-bottom:10px;"ID= "Foodlist">2 <ul>3 {eq name= "list[' state ']" value= ' 0 '}4 <Li>Please add menu type</Li>5 {Else}6 {eq name= "list[' Count ']" value= ' 0 '}7 <Li>Please add a menu item</Li>8 {Else}9 {volist name= "list[' data ']" id= ' list '}Ten <Lidata-p= ' {eqname= "$list. Food_p1"value= ". xx"}0{/eq}{$list. food_p1} ' data-u= ' {$list. food_u1} 'Data-id= ' {$list. food_id} '>{$list. Food_name}<I>{$list. Food_code}</I></Li> One {/volist} A {/eq} - {/eq} - </ul> the <Divclass= "CL"></Div> - </Div>
JS Code
1 $ ("#foodCode"). KeyUp (function () {2 $ ("#foodList ul Li"). Stop (). Hide (). Filter (": Contains (' "+ ($ (this). Val ()) +" ') "). Show ();//contains matches the contents of the text
3 });
PHP only does the output data, so it's not released here.
Fast Search for JS