Simulate drop-down options box select
In the case of CSS3, the dropdown box is still unable to meet the needs of PD, so with the AutoSearch, there is a mock drop-down box. Effects such as:
Select
Demo Please click here to view. http://www.lovewebgames.com/jsmodule/select.htmlSource View Download Please click here Https://github.com/tianxiangbing/select call Example
<select name= "Select" id= "select" > <option value= "1" > Please select </option> <option value= "1" > Male </o ption> <option value= "0" selected= "true" > Female </option> <option value= "Ten" disabled= "true" > "' Shemale </option></select><select id="Select2"></select><input type="Text" id= "Select3" style= "height:30px;" value= "2"><a id="Select4" data-value= "1"></a>
<link rel= "stylesheet" type= "Text/css" href= ". /src/select.css "><script type="Text/javascript" src= ". /src/jquery-1.11.2.js "></script><script type=" Text/javascript "src=". /src/select.js "></script><script>varselect =NewSelect (); Select.init ({target:' #select '});$(' #select2 '). Select ({width:100, Model: [{text:"Please select", Value:"1" }]});varModel=[{text:"Zhejiang Zhejiang, Zhejiang, Zhejiang, Zhejiang", Value:"1"},{Text:Hangzhou, Value:"2"},{Text:Ningbo, Value:"3"},{Text:Hubei, Value:"4"},{Text:Shanghai, Value:"5"},{Text:"Wanda", Value:"6"},{Text:"The beauty of Things", Value:"7", Disabled:true},{Text:China, Value:"8"},{Text:Foreign, Value:"9" }];$(' #select3 '). Change (function() {Console.log (' Select a: ' +$ ( This). Val ())//or selected .}). Select ({width:100, MaxHeight:300, MaxWidth:' Auto ', Model:model});varsel=$ (' #select4 '). Select ({width:100, Height:24 })[0];settimeout (function() {sel.setdata (model);//Changing data sources dynamically},2000);</script>
API Properties Target:
[DOM|String|$]
To change the node to select, it can be the original is a select, or other elements, if it is other elements, the priority to take value as the selected item, otherwise take Data-value value;
Model
Array
Data source Array [value: ' 1 ', Text: ' Text ', disabled:false], if none, will go to option,disabled can control whether optional, option on the same
Multi
bool
Whether to choose more
Disabled
bool
is available, False is available by default, and if not, the target's disabled or target.hasclass (' disabled ') will be used to determine if it is available
Method SetData:
function(data)
Change the data source to the array [value: ' 1 ', Text: ' Text ', disabled:false]
Selected
function(val,txt)
The callback after the selection
Event Change:
[value]
Triggered when the selected item changes
Blur
triggered when hidden
[JS Open Source Component development] simulation drop-down option box select