Fast Search for JS

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.