[JS Open Source Component development] simulation drop-down option box select

Source: Internet
Author: User

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

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.