input type='search' implements the search box
If you want to implement a text search function, when input is required, the keyboard Enter button prompt displays "Search". The effect is as follows:
Start~
input type=text cannot achieve this effect. I googled it and found that the type=search added in html5 can do it (but it requires Input type=search is wrapped with a form with action attributes).
<p class="search-input-wrap clearfix"> <p class="form-input-wrap f-l"> <form action="" class="input-kw-form"> <input type="search" autocomplete="off" name="baike-search" placeholder="请输入关键词" class="input-kw"> </form> <i class="iconfont if-message"></i> <i class="iconfont if-close"></i> </p> <i class="search-cancel f-l">取消</i> </p>
But type=search will have many default styles and behaviors. The ones encountered during this development are:
The search history will be displayed in the drop-down box by default;
"x" will automatically pop up when typing. The style of "x" is different on different mobile phones;
The input box on the IOS phone (iphone6 ios10 when tested) is oval.
But we want the style to be displayed according to our customized style , and can be unified on each mobile phone.
So after several Google searches, I got the answer:
Set input autocomplete="off" to remove the pop-up drop-down box;
Hide the default "x":
input[type="search"]::-webkit-search-cancel-button{ display: none; }
Set the style for ios and remove the input oval under ios:
-webkit-appearance: none;
At the same time, don’t forget that if you want to use ajax when submitting a search, you can prevent the default behavior of the form:
container.on('submit', '.input-kw-form', function(event){ event.preventDefault(); })
For more input type="search" related articles about implementing search boxes, please pay attention to the PHP Chinese website!

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

AI Hentai Generator
Generate AI Hentai for free.

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)

Hot Topics



Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an
