【HTML5 jquery】The search matching effect, or search filtering, when you enter a character in the text box, if there is content starting with this in the list below, it will automatically be used for you Show related content.
Only some examples are listed. You can improve it yourself when you use it. The code only provides you with an idea. I hope it will be helpful to you.
HTML
<link rel="stylesheet" type="text/css" href="http://www.jq22.com/jquery/bootstrap-3.3.4.css"> <div class="g-container"> <form action="" class="basic-grey"> <div class="form-group"> <label for="lastname" class="control-label"> 公司选择: </label> <div class="Companies"> <input class="form-control" type="text" placeholder="请选择" id="js-groupId"> <input type="hidden" id="groupId"> <ul id="groupid"> <li data-id="827"><a href="javascript:void(0)">厦门集众筹智科技有限公司</a></li> <li data-id="826"><a href="javascript:void(0)">苏州高新区文体发展有限公司</a></li> <li data-id="825"><a href="javascript:void(0)">美罗城test</a></li> <li data-id="824"><a href="javascript:void(0)">深圳市高收益科技开发有限公司</a></li> <li data-id="823"><a href="javascript:void(0)">深圳市蜗爱生活科技开发有限公司</a></li> <li data-id="815"><a href="javascript:void(0)">深圳市宇恒乐便利店管理有限公司</a></li> <li data-id="814"><a href="javascript:void(0)">广东胜佳超市有限公司</a></li> <li data-id="813"><a href="javascript:void(0)">顺义李先生说</a></li> <li data-id="812"><a href="javascript:void(0)">十足集团股份有限公司</a></li> <li data-id="811"><a href="javascript:void(0)">宏图三胞高科技术有限公司</a></li> <li data-id="810"><a href="javascript:void(0)">九州连锁超市公司</a></li> <li data-id="809"><a href="javascript:void(0)">李先生</a></li> <li data-id="808"><a href="javascript:void(0)">李先生牛肉面快餐厅</a></li> <li data-id="807"><a href="javascript:void(0)">李先生牛肉面快餐厅</a></li> <li data-id="806"><a href="javascript:void(0)">美宜佳便利店有限公司</a></li> <li data-id="805"><a href="javascript:void(0)">上海一嗨汽车租赁有限公司</a></li> <li data-id="804"><a href="javascript:void(0)">龙湖商业地产(重庆区)</a></li> <li data-id="803"><a href="javascript:void(0)">阜阳华联集团股份有限公司</a></li> <li data-id="802"><a href="javascript:void(0)">百万庄园</a></li> <li data-id="801"><a href="javascript:void(0)">百万庄园</a></li> <li data-id="800"><a href="javascript:void(0)">上海恭胜酒店管理有限公司</a></li> <li data-id="799"><a href="javascript:void(0)">北京好伦哥餐饮有限公司</a></li> <li data-id="798"><a href="javascript:void(0)">富驿酒店集团有限公司</a></li> </ul> </div> </div> </form> </div>
CSS:
div,li,ul { margin:0; padding:0; } ul li { list-style:none; } .basic-grey { width:600px; margin:5% 10%; } .basic-grey .Companies { position:relative; } .basic-grey .Companies ul { position:relative; height:210px; width:100%; overflow-y:auto; border:1px solid #DDD; display:none; } .basic-grey .Companies ul li { padding:3px 12px; } .basic-grey .Companies ul li:hover { background-color:#bebebe; cursor:pointer; } .basic-grey .Companies ul li.top { position:absolute; top:0; }
js:
jQuery.expr[':'].Contains = function(a, i, m) { return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; function filterList(list) { $('#js-groupId').bind('input propertychange', function() { var filter = $(this).val(); if (filter) { $matches = $(list).find('a:Contains(' + filter + ')').parent(); $('li', list).not($matches).slideUp(); $matches.slideDown(); } else { $(list).find("li").slideDown(); } }); } $(function() { filterList($("#groupid")); $('#js-groupId').bind('focus', function() { $('#groupid').slideDown(); }).bind('blur', function() { $('#groupid').slideUp(); }) $('#groupid').on('click', 'li', function() { $('#js-groupId').val($(this).text()) $('#groupId').val($(this).data('id')) $('#groupid').slideUp() }); })
The above is the detailed content of How to do search matching in html5?. For more information, please follow other related articles on the PHP Chinese website!

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

The function of HTML is to define the structure and content of a web page, and its purpose is to provide a standardized way to display information. 1) HTML organizes various parts of the web page through tags and attributes, such as titles and paragraphs. 2) It supports the separation of content and performance and improves maintenance efficiency. 3) HTML is extensible, allowing custom tags to enhance SEO.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.