How to do search matching in html5?
【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!

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

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

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Tocenteradivhorizontally,usemargin:0autowithadefinedwidth.2.Forhorizontalandverticalcentering,applydisplay:flexontheparentwithjustify-content:centerandalign-items:center.3.Alternatively,useCSSGridwithplace-items:centerforbothdirections.4.Asafallback,

AdefinitionlistinHTML5iscreatedusingtheelementtogroupterms()withtheirdefinitions(),allowingmultipletermstoshareadefinitionoratermtohavemultipledefinitions,makingitidealforFAQs,glossaries,metadata,andcontactdetailswhileimprovingaccessibilityandSEOthro

TheelementinHTML5isusedtomarkupself-containedcontentlikeimages,diagrams,orcodesnippetsthatcanstandindependentlywithinadocument.Itcanbepairedwiththeoptionalelementtoprovideacaptionortitle,whichmayappearasthefirstorlastchildinside.Thiscombinationenhanc

TocreatesubscriptandsuperscripttextinHTML,usetheandtags.1.Usetoformatsubscripttext,suchasinchemicalformulaslikeH₂O.2.Usetoformatsuperscripttext,suchasinexponentslike10²orordinalslike1ˢᵗ.3.Combinebothtagswhenneeded,asinscientificnotationlike²³⁵₉₂U.The

Use elements to represent the output of a program, script or computer system, such as terminal display, error message or code results; 2. Use it when it is necessary to distinguish computer-generated content from other text to improve accessibility and semantic accuracy; 3. The basic syntax is Sampleoutputtext; 4. It can be combined with the format, or nested to clearly distinguish code input and output; 5. Best practices include only being used for real system output, avoiding visual abuse, and cooperating with CSS rather than substitute semantics; 6. Although screen readers may not be broadcasted specifically, correct use can enhance document structure and assistive technology understanding. Therefore, it is an important semantic tag that improves HTML accuracy and accessibility.

Use tags to define the main navigation link blocks of the web page to improve accessibility and SEO; 2. Use only in main navigation areas such as main navigation menus, sidebar links, paging or catalogs, rather than each link; 3. Pack the links in it and recommend or organize links to enhance semantics and accessibility; 4. Avoid too many or unnecessary blocks to ensure clear structure; 5. Add aria-labels to multiple to distinguish uses; 6. Do not put non-navigation content such as copyright information, and avoid missing structured markings of link lists. Correct use can effectively improve the usability and organization of the website.

ThecontenteditableattributemakesHTMLelementseditablebyaddingcontenteditable="true"toelementslikediv,p,orh1–h6.2.UseJavaScripttoretrievecontentviainnerHTMLforformattedtextortextContentforplaintext.3.Listenforchangesusingtheinputeventtocaptur

rel="preload" is used to load key resources in advance to improve page performance. 1. Use syntax and specify the as attribute; 2. Preload key resources such as fonts, style sheets, scripts, pictures, etc., and the font needs to be added crossorigin; 3. It can be loaded according to conditions in combination with media attributes; 4. Follow best practices such as loading only key resources on the first screen, avoiding excessive use, and correctly setting type and crossorigin; 5. Modern browsers widely support it, and can dynamically add or perform gradual enhancement processing through JavaScript to ensure that the page still works normally when it is not supported.
