JS search box for automatic search function

Source: Internet
Author: User

When doing the project, the boss let me encapsulate a search function, similar to Baidu

After entering the character, you can automatically search for data, and there will be a drop-down box for the user to choose, I think my boss has a problem, there are so many plug-ins on the net, not only the package, performance has also been optimized, what functions have, he does not, must I use the original JS write, write yarn, I spit in the But still want to do, in order to pay and bow, so I this small white will bite the bullet, there must be a lot of shortcomings, there is no encapsulation, is to think where to write where, to everyone when the negative view, if you see, you can point to me, let me progress

Because I was written in the project, so there are a lot of things and everyone's affirmation is not the same, look at the idea on the line, the details can be seen, but there must be a problem, the HTML code to look at their own wording, I was to the search box to add the KeyUp event, the Change event can also, But one drawback is that it's not a good idea to lose focus.

This is the search data.

This is a drop-down box, this is a bit complicated, because it also involves clicking on other places to hide and click the search box to display the problem, it is very simple to say, but it is not so easy to do, I write when the head is messy, so the code is very messy

JS search box for automatic search function

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.