컴

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

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

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

기능적으로 조금만 더 추가하면 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,188건
+
제목 글쓴이 날짜 조회
16-06-03 조회 3,001
15-07-30 조회 3,399
15-06-08 조회 5,544
15-05-27 조회 4,403
15-01-08 조회 6,696
14-12-30 조회 5,428
14-10-10 조회 5,420
14-08-13 조회 6,332
14-08-11 조회 5,192
14-08-06 조회 6,527
14-03-19 조회 7,422
13-04-26 조회 9,582
12-12-15 조회 5,101
12-12-15 조회 7,337
12-12-11 조회 5,468
12-11-21 조회 6,000
12-10-11 조회 5,082
12-10-03 조회 4,776
12-09-20 조회 6,078
12-09-02 조회 4,255
12-08-29 조회 5,254
12-08-29 조회 4,141
12-08-24 조회 4,240
12-08-18 조회 4,469
12-08-17 조회 4,508
12-08-16 조회 3,764
12-08-06 조회 5,540
12-08-05 조회 4,829
12-08-03 조회 4,545
12-08-03 조회 4,686
12-07-29 조회 3,546
12-07-24 조회 4,132
12-07-22 조회 3,603
12-07-20 조회 4,356
12-07-19 조회 4,705
12-07-19 조회 3,938
12-07-19 조회 3,883
12-07-19 조회 5,548
12-07-19 조회 3,492
12-07-18 조회 5,174
12-07-15 조회 4,145
12-07-14 조회 3,825
12-07-12 조회 4,501
12-07-11 조회 3,774
12-07-11 조회 3,496
12-07-11 조회 3,462
12-07-10 조회 4,643
12-07-09 조회 3,396
12-07-09 조회 4,223
12-07-09 조회 4,638
12-07-08 조회 4,558
12-07-07 조회 5,480
12-07-06 조회 4,737
12-07-06 조회 4,007
12-07-06 조회 3,891
12-07-06 조회 3,819
12-07-02 조회 5,499
12-07-02 조회 4,199
12-06-29 조회 3,723
12-06-28 조회 4,349
12-06-26 조회 3,842
12-06-26 조회 4,963
12-06-21 조회 3,939
12-06-20 조회 4,643
12-06-20 조회 4,270
12-06-15 조회 4,625
12-06-15 조회 4,361
12-06-13 조회 7,378
12-06-05 조회 7,354
12-06-04 조회 3,933
12-06-03 조회 3,777
12-05-31 조회 3,780
12-05-28 조회 6,621
12-05-27 조회 3,856
12-05-25 조회 3,992
12-05-23 조회 4,401
12-05-21 조회 5,109
12-05-17 조회 4,047
12-05-17 조회 3,970
12-05-09 조회 4,043
12-05-07 조회 4,293
12-05-02 조회 4,487
12-05-01 조회 4,661
12-04-30 조회 3,407
12-04-30 조회 4,352
12-04-25 조회 4,437
12-04-25 조회 4,866
12-04-24 조회 3,832
12-04-24 조회 4,599
12-04-23 조회 3,603
12-04-20 조회 3,242
12-04-17 조회 5,431
12-04-16 조회 4,372
12-04-14 조회 3,655
12-04-14 조회 3,683
12-04-14 조회 3,735
12-04-13 조회 3,356
12-04-13 조회 4,542
12-04-13 조회 6,180
12-04-12 조회 3,345