Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> Insert title here </title>
<Style type = "text/css">
Body {margin: 0px; padding: 0px ;}
Ul {margin: px; padding: 0px; list-style-type: none ;}
</Style>
<Script src = "jquery-1.8/jquery-1.8.0.js"> </script>
<Script>
$ (Function (){
A ();
Onclick ();
$ ("# Txt"). bind ("keyup", function (){
Txtchange (0 );
});
});
Function (){
Ularray = [];
Var data = [{}, {}];
// Input data to ul
Var ul = $ ("# ul1 ");
$. Each (data, function (index, item)
{
Var li = $ ("<li> </li> ");
$. Each (item, function (name, value)
{
Var span = $ ("<span> </span>" 2.16.html (value );
Li. append (span );
Ularray. push (value );
});
Ul. append (li );
});
// Sort
Ularray. sort ();
};
// Keyup event
Function txtchange (flag)
{
Var textObj = $ ("# txt"). val ();
Var divObj = $ ("# div1" pai.html ();
Var array = [];
With (divObj)
{
Var ulHTML = divObj. match (/<[^>] *>/) [0]; // get the start tag
Val = ularray + ""; // convert to string
For (var I = 0; I <ularray. length; I ++)
{
If (val. split (",") [I]. indexOf (textObj )! =-1 | flag) // splits the string into an array.
{
Array [array. length] = "<li> <span>" + ularray [I] + "</span> </li> ";
};
}; // Put the new set into an array
Var liHtml = "";
$. Each (array, function (item, val ){
LiHtml + = val;
}); // Remove the comma between Arrays
DivObj = ulHTML + liHtml + "</ul> ";
$ ("# Ul1" pai.html (divObj );
Onclick (); // click the new array
};
};
// Span Click Event
Function onclick (){
$ ("# Ul1 li span"). click (function ()
{
Var oli = $ (this );
Var otxt00000000(this0000.html ();
$ ("# Txt"). empty (). val (otxt );
});
};
</Script>
</Head>
<Body>
<Center>
<Form>
<Input id = "txt" type = "text"/>
Automatic prompt
<Div id = "div1">
<Ul id = "ul1">
</Ul>
</Div>
</Form>
</Center>
</Body>
</Html>