컴

레이어를 이용한 셀렉트 박스

· 2014-05-09 (금) 19:20:40 · 5039
아래 소스는 제가 퍼블리싱 하면서 만들었던 레이어 셀렉트 박스 소스인데요.

제이쿼리를 이용해서 아주 간단하게 만든것이에요.

기능적으로 조금만 더 추가하면 select tag와 동일하게 사용할 수 있을 거라
생각해요.

제이쿼리와 css를 좀 아시면 금방 해석 가능할 것에요.

$(document).ready(function() {
    ////////////////////////////////////////////////////////////////////////////////////
    //javascript:location.href='#'     <====  # 부분에 url을 넣는다.
    ////////////////////////////////////////////////////////////////////////////////////
    var selecttag = "\
            <div id='choicevalue'><img src=\"/images/engicon.png\" alt=\"ENG\" /></div>\
            <dl>\
                <dd onClick=\"javascript:location.href='#'\"><img src=\"/images/engicon.png\" alt=\"ENG\" width=80 height=20/></dd>\
                <dd onClick=\"javascript:location.href='#'\"><img src=\"/images/koricon.png\" alt=\"KOR\" width=80 height=20 /></dd>\
            </dl>\
    ";
    // GNB
    $(".gnb").append($("<li class=\"end\" id=\"selectmenu\">"+selecttag+"</li>"));    //<=== 이부분에 셀렉트박스 추가



    //////////////////////////////////////////////////////////////////////////////////////////////
    //레이어 셀렉트박스
    //////////////////////////////////////////////////////////////////////////////////////////////
        var defaultheight = 24;
        var defaultwidth = 80;
        var maxheight = defaultheight;
        var top = defaultheight + 4;

        $('#selectmenu').css({'padding':'2px 0','cursor':'pointer','height':defaultheight+'px','width':defaultwidth+'px','color':'#d7d7d7','position':'relative','z-index':'1000'});
        function ShowSelect(){
            $('#choicevalue').css({'clear':'both','padding':'2px 0','height':defaultheight+'px','width':defaultwidth+'px'});        
            
            var ddcnt = $('#selectmenu').children("dl").children("dd").length;
            maxheight = defaultheight * ddcnt;
            $('#selectmenu').children("dl").css({"clear":"both","position":"absolute","left":"0px","top":top+"px","z-index":"10000","height":maxheight+"px","width":defaultwidth+"px",'border':'1px solid #fff','background':'#6d656a'});
            $('#selectmenu').children("dl").children("dd").css({"clear":"both","height":defaultheight+"px","width":defaultwidth+"px"},{'padding':'2px 0px'});
            $('#selectmenu').css({"height":(maxheight+defaultheight+10)+"px"});
        }

        function HideSelect(){
            $('#selectmenu').animate({'height':defaultheight+'px'});    
        }
        $('#selectmenu').mouseenter(function(){
            ShowSelect();
        });

        $("#selectmenu").children("dl").children("dd").click(function(){
            $('#choicevalue').html($(this).html());
            HideSelect();
        });
        $('#selectmenu').mouseleave(function(){
            HideSelect();
        });

        ShowSelect();

        setTimeout(function(){
            HideSelect();
        },2000);
    //////////////////////////////////////////////////////////////////////////////////////////////
});
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,187건
+
제목 글쓴이 날짜 조회
14-09-19 조회 3,759
14-09-19 조회 4,011
14-09-19 조회 4,394
14-09-19 조회 4,029
14-09-19 조회 4,491
14-09-19 조회 3,956
14-09-19 조회 4,139
14-09-19 조회 4,240
14-09-19 조회 3,979
14-09-19 조회 4,031
14-09-19 조회 4,104
14-09-19 조회 5,062
14-09-19 조회 4,004
14-09-18 조회 4,081
14-09-18 조회 3,935
14-09-18 조회 4,208
14-09-18 조회 4,037
14-09-18 조회 3,730
14-09-18 조회 4,310
14-09-18 조회 4,640
14-09-18 조회 4,292
14-09-18 조회 4,133
14-09-18 조회 4,283
14-09-18 조회 4,992
14-09-18 조회 4,155
14-09-18 조회 4,121
14-09-18 조회 5,536
14-09-18 조회 5,420
14-09-18 조회 4,233
14-09-18 조회 4,735
14-09-18 조회 4,348
14-09-18 조회 4,142
14-09-18 조회 4,340
14-09-18 조회 4,939
14-09-17 조회 4,101
14-09-16 조회 4,903
14-09-16 조회 5,122
14-09-16 조회 3,833
14-09-15 조회 4,033
14-09-15 조회 3,600
14-09-13 조회 4,688
14-09-12 조회 4,498
14-09-12 조회 3,877
14-09-12 조회 3,772
14-09-11 조회 3,497
14-09-11 조회 4,320
14-09-11 조회 4,595
14-09-10 조회 3,423
14-09-10 조회 3,609
14-09-03 조회 3,832
14-09-03 조회 3,767
14-09-03 조회 4,036
14-09-03 조회 5,692
14-09-01 조회 5,481
14-09-01 조회 4,880
14-09-01 조회 4,309
14-08-30 조회 4,342
14-08-30 조회 5,605
14-08-29 조회 4,559
14-08-28 조회 6,037
14-08-28 조회 6,638
14-08-28 조회 6,890
14-08-27 조회 6,912
14-08-27 조회 7,074
14-08-27 조회 5,578
14-08-27 조회 2만
14-08-27 조회 4,249
14-08-26 조회 4,281
14-08-26 조회 4,213
14-08-26 조회 4,082
14-08-26 조회 4,033
14-08-26 조회 3,863
14-08-26 조회 3,728
14-08-26 조회 4,367
14-08-26 조회 4,058
14-08-26 조회 3,992
14-08-26 조회 4,173
14-08-26 조회 4,000
14-08-26 조회 3,856
14-08-26 조회 4,069
14-08-26 조회 4,154
14-08-26 조회 4,154
14-08-26 조회 4,007
14-08-26 조회 3,901
14-08-26 조회 3,859
14-08-26 조회 4,141
14-08-26 조회 3,759
14-08-26 조회 3,903
14-08-26 조회 3,679
14-08-26 조회 3,521
14-08-26 조회 3,830
14-08-26 조회 4,423
14-08-26 조회 3,703
14-08-26 조회 3,847
14-08-26 조회 3,785
14-08-26 조회 3,648
14-08-26 조회 3,803
14-08-26 조회 3,718
14-08-26 조회 3,944
14-08-26 조회 4,428