jquery Simple Search box

Source: Internet
Author: User

<!doctype html>
<meta charset= "Utf-8" >
<title>jquery Simple search Box-jq22.com</title>
<script src= "Http://libs.baidu.com/jquery/1.9.1/jquery.min.js" ></script>
<style>
* {
margin:0;
padding:0;
}
UL Li {
List-style:none;
}
A
Text-decoration:none;
}
. box {
width:600px;
}
. box1 {
width:300px;
Height:auto;
margin:30px 70px;
Float:left;
position:relative;
}
. box1. Inputcont {
width:200px;
height:36px;
line-height:36px;
Position:absolute;
top:0;
left:0;
}
. box1 #dynamicUl {
width:200px;
Height:auto;
BORDER:1PX solid yellow;
Position:absolute;
left:0;
top:40px;
}
. box1 #dynamicUl Li {
width:200px;
height:36px;
line-height:36px;
border-bottom:1px solid #ccc;
}
. box2 {
width:200px;
Height:auto;
Float:right;
margin-top:-30px;
}
. box2 #data {
width:200px;
Height:auto;
}
</style>
<body>
<div class= "box" >
<div class= "Box1" >
<input type= "text" placeholder= "Please enter phone number" class= "Inputcont" >
<ul id= "Dynamicul" >
</ul>
</div>
<div class= "Box2" >
<ul id= "Data" >
<li>1</li>
<li>22</li>
<li>123</li>
<li>13571</li>
<li>111</li>
</ul>
</div>
</div><script>
$ (function () {
var arr = [];
$ (' #data '). Children (). each (function () {
var Litext = $ (this). text ();
Arr.push (Litext);
});
$ ('. Inputcont '). On (' KeyUp ', function () {
$ (' #dynamicUl '). Find ("Li"). Remove ();
$ (' #dynamicUl '). Show ();
var Inputcont = $ ('. Inputcont '). Val ();
for (var i = 0; i < arr.length; i++) {
if ((Arr[i].indexof (inputcont))! =-1) {
$ (' #dynamicUl '). Append ($ (' <li onclick= "Removeul (This)" > ' + arr[i] + ' </li> '));
}
}
})
$ (' #dynamicUl '). On (' Click ', ' Li ', function () {
$ ('. Inputcont '). Val ($ (this). text ());
})
Removeul = function () {
$ (' #dynamicUl '). Hide ();
}
}) </script>
</body>

jquery Simple Search box

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.