First view results
Function:When you click the drop-down box, the drop-down list below is automatically displayed, and is added based on the search entered in the input box. It is automatically searched in the background and uploaded to the foreground to display the page.
Js used:
Copy codeThe Code is as follows:
Var $ xialaSELECT;
$ (Document). ready (function (){
InitXialaSelect ();
InitSearch ();
});
Var temptimeout = null;
Var query = "";
Function searchDev (key ){
// If (key = "") return;
Query = key;
ClearTimeout (temptimeout );
Temptimeout = setTimeout (findUnSaved, 500 );
}
Function findUnSaved ()
{
// Alert ("dd ");
// If (1 = 1) return;
$. Ajax ({
Type: "post ",
Data: {'query': query },
Url: path + "/tList. action ",
Success: function (data ){
Xiala (data );
},
Error: function (data ){
Alert ("loading failed. Please try again! ");
}
});
}
Function initSearch ()
{
// Define a drop-down button layer, configure the style (Position, positioning point coordinate, size, background image, Z axis), and append it to the end of the text box
$ XialaDIV = $ ('<div> </div> 'salary .css ('position', 'absolute'salary .css ('left', $ (' # province '). position (). left + $ ('# province '). width ()-15 + 'px'0000.css ('top ',
$ ('# Province '). position (). top + 4 + 'px'background .css ('background ', 'transparent url (.. /images/lala.gif) no-repeat top left'detail .css ('height', '16px'detail .css ('width ',
'15px'0000.css ('z-Index', '20140901 ');
$ ('# Province'). after ($ xialaDIV );
// Move the mouse to modify the background image position
$ XialaDIV. mouseover (function (){
Using xialadiv.css ('background-position', '2017-16px ');
});
// Move the mouse out to modify the background image position
$ XialaDIV. mouseout (function (){
Using xialadiv.css ('background-position', '2017-0px ');
});
// Press the mouse to modify the background image position
$ XialaDIV. mousedown (function (){
Using xialadiv.css ('background-position', '2017-32px ');
});
// Release the mouse to modify the background image position
$ XialaDIV. mouseup (function (){
Using xialadiv.css ('background-position', '2017-16px ');
If ($ xialaSELECT)
$ XialaSELECT. show ();
});
$ ('# Province'). mouseup (function (){
Using xialadiv.css ('background-position', '2017-16px ');
$ XialaSELECT. show ();
});
}
Var firstTimeYes = 1;
// The drop-down box div of the text box
Function xiala (data ){
// First time
If ($ xialaSELECT)
{
$ XialaSELECT. empty ();
}
// Define a drop-down BOX layer, configure the style (Position, positioning point coordinate, width, and Z axis), and hide it first
// Define five option layers, configure the style (width, Z axis must be higher than the drop-down box), add the name and value attributes, and add the drop-down box Layer
$ XialaSELECT. append (data );
If (firstTimeYes = 1)
{
FirstTimeYes = firstTimeYes + 1;
} Else {
$ XialaSELECT. show ();
}
}
Function initXialaSelect ()
{
$ XialaSELECT = $ ('<div> </div> 'salary .css ('position', fill ('border', '1px solid trim ('left', '125px'salary .css
('Top', $ ('# province '). position (). top + $ ('# province '). height () + 6 + 'px'0000.css ('width', $ ('# province '). width () + 'px'0000.css ('z-Index', percentile ('max-height', '600px ');
$ ('# Province'). after ($ xialaSELECT );
// Move the mouse at the option layer to the remove Style
$ XialaSELECT. mouseover (function (event ){
If (((event.tar get). attr ('name') = 'option '){
// When moving in, the background color becomes deeper and the word color becomes white
Watermark (event.target).css ('background-color', 'background 000077').css ('color', 'white ');
Vertex (event.tar get). mouseout (function (){
// If the color is removed, the background color turns white and the font color turns black.
Watermark (event.target).css ('background-color', '{ffff'}.css ('color', '#000000 ');
});
}
});
// Click the position to determine the pop-up display
$ XialaSELECT. mouseup (function (event ){
// If it is a drop-down button layer or a drop-down BOX layer, the drop-down BOX layer is still displayed
If (event.tar get = $ xialaSELECT. get (0) | event.tar get = $ xialaDIV. get (0 )){
$ XialaSELECT. show ();
}
Else {
// If it is an option layer, the value of the text box is changed.
If (((event.tar get). attr ('name') = 'option '){
// Pop-up value observation
Certificate ('{nce'}.val(%(event.target}.html ());
Certificate ('{d'{.val({(event.tar get). attr ("d "));
// If seleced host then hidden the dev type
If(detail (event.tar get). attr ("ass") = 3305)
{
$ ("# Ype"). hide ();
$ ("# Ost"). val (1 );
} Else {
$ ("# Ype"). show ();
$ ("# Ost"). val (-1 );
}
}
// If it is another location, the drop-down box Layer
If ($xialaSELECT.css ('display') = 'block '){
$ XialaSELECT. hide ();
}
}
});
$ XialaSELECT. hide ();
}
Var k = 1;
Document. onclick = clicks;
Function clicks ()
{
If (k = 2 ){
K = 1;
If ($ xialaSELECT)
{
If ($xialaSELECT.css ('display') = 'block '){
$ XialaSELECT. hide ();
}
}
} Else {
K = 2;
}
}
Copy codeThe Code is as follows:
. CBA {
Width: 150px;
Height: 18px;
}
. Selectlala {
Text-align: left;
Line-height: 20px;
Padding-left: 5px;
Width: 147px;
Font-family: Arial, verdana, tahoma;
Height: 20px;
}
<Input type = "text" name = "province" id = "province" class = "CBA" onkeyup = "searchDev (this. value)"/>