컴

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

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

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

기능적으로 조금만 더 추가하면 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건
+
제목 글쓴이 날짜 조회
13-10-29 조회 7,910
13-10-28 조회 8,740
13-10-28 조회 3,925
13-10-28 조회 3,463
13-10-27 조회 3,082
13-10-26 조회 3,797
13-10-25 조회 3,536
13-10-24 조회 3,497
13-10-24 조회 3,241
13-10-24 조회 3,560
13-10-24 조회 4,149
13-10-23 조회 4,314
13-10-23 조회 3,570
13-10-22 조회 4,805
13-10-21 조회 3,324
13-10-20 조회 3,654
13-10-18 조회 4,572
13-10-17 조회 4,944
13-10-15 조회 4,831
13-10-11 조회 4,693
13-10-10 조회 5,301
13-10-10 조회 3,766
13-10-08 조회 4,287
13-10-03 조회 6,364
13-10-02 조회 4,232
13-10-02 조회 4,511
13-10-02 조회 4,279
13-10-02 조회 3,761
13-10-02 조회 4,020
13-10-02 조회 3,872
13-10-02 조회 4,231
13-09-29 조회 4,786
13-09-29 조회 4,235
13-09-29 조회 4,110
13-09-29 조회 6,699
13-09-29 조회 4,329
13-09-27 조회 3,641
13-09-27 조회 4,274
13-09-24 조회 3,332
13-09-24 조회 3,610
13-09-18 조회 4,027
13-09-17 조회 3,888
13-09-16 조회 8,090
13-09-16 조회 5,455
13-09-16 조회 4,413
13-09-15 조회 3,259
13-09-13 조회 4,958
13-09-13 조회 3,437
13-09-13 조회 3,730
13-09-12 조회 3,532
13-09-11 조회 6,322
13-09-10 조회 3,593
13-09-10 조회 6,188
13-09-10 조회 3,953
13-09-09 조회 4,329
13-09-09 조회 4,979
13-09-07 조회 5,084
13-09-07 조회 3,168
13-09-06 조회 3,285
13-09-06 조회 3,908
13-09-06 조회 3,268
13-09-05 조회 3,446
13-09-05 조회 9,616
13-09-04 조회 3,141
13-09-04 조회 3,409
13-09-04 조회 3,089
13-09-03 조회 3,186
13-09-03 조회 3,599
13-08-30 조회 3,424
13-08-30 조회 4,517
13-08-29 조회 4,472
13-08-28 조회 3,979
13-08-28 조회 8,164
13-08-27 조회 4,149
13-08-26 조회 4,355
13-08-26 조회 3,584
13-08-26 조회 4,879
13-08-23 조회 4,169
13-08-23 조회 5,921
13-08-22 조회 5,454
13-08-22 조회 4,675
13-08-22 조회 5,178
13-08-22 조회 4,752
13-08-22 조회 4,670
13-08-22 조회 3,656
13-08-20 조회 3,913
13-08-18 조회 8,611
13-08-18 조회 5,511
13-08-17 조회 6,148
13-08-17 조회 4,964
13-08-17 조회 4,418
13-08-14 조회 3,448
13-08-12 조회 4,456
13-08-11 조회 3,629
13-08-09 조회 4,136
13-08-08 조회 5,371
13-08-08 조회 5,120
13-08-08 조회 4,509
13-08-08 조회 9,413
13-08-08 조회 5,611