Write a Select plugin that is coarse and slow to modify

Source: Internet
Author: User

$.createselect=function(Options) {$ (options.selectors). each (function(Index, item) {$ (item). each (function(index, selector) {if($ (selector). Is (' SELECT ')){                varOptionlength = $ ( This). Find (' option '). length; if(Optionlength > 0){                    varDivclass = $ ( This). attr (' class '); varJsscroll = ' <div class= ' ' +divclass+ ' selector ' ><span> ' +$ ( This). Find (' option '). EQ (0). Text () + ' </span><ul> ';  for(vari = 0; i < optionlength; i++){                        var$op = $ ( This). Find ("option"). EQ (i); Jsscroll+ = "<li val=" + $op. attr ("value") + ">" + $op. HTML () + "</li>\n"; } jsscroll+ = ' </ul></div> '; $( This). After (Jsscroll); $( This). Hide (); var$divW = $ ('. ') +divclass). Outerwidth (); $(‘.‘ +divclass). Find (' span '). CSS ({' width ': $divW-5}). On (' click ',function(){                                   $( This). Next (' UL '). Show (); }). End (). Find (' ul '). css ({' Width ': $divW}). Find (' Li '). On ({' MouseOver ':function(){$( This). addclass (' cur ')},                        ' Mouseout ':function(){$( This). Removeclass (' cur ')},                        ' Click ':function(){                        $( This). Closest (' ul '). Hide (). Siblings (' span '). Text ($ ( This). text ());                }                    }); }}) ({}$.createselect }})})' Selectors ': ['. Selector1 ']})
. Selector{Border:1px solid #ccc;position:relative;}. Selector span{Padding-left:5px;background:URL (icon.png) no-repeat 265px-19px;Display:Inline-block;width:100%;Height:100%;cursor:Pointer;}. Selector ul{position:Absolute;Top:31px; Left:-1px;width:300px;Border:1px solid #ccc;Display:None;}. selector ul Li{Height:25px;Line-height:25px;Padding-left:5px;cursor:Pointer;}. Selector ul li.cur{background:#eee;}

A select plugin written by

is coarse; modify it slowly

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.