컴

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

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

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

기능적으로 조금만 더 추가하면 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건
+
제목 글쓴이 날짜 조회
14-08-26 조회 3,445
14-08-26 조회 3,672
14-08-26 조회 4,272
14-08-26 조회 3,573
14-08-26 조회 3,769
14-08-26 조회 3,695
14-08-26 조회 3,513
14-08-26 조회 3,661
14-08-26 조회 3,588
14-08-26 조회 3,773
14-08-25 조회 4,140
14-08-16 조회 4,264
14-08-12 조회 4,134
14-08-05 조회 3,966
14-08-04 조회 4,821
14-08-04 조회 3,989
14-08-01 조회 5,315
14-07-29 조회 4,374
14-07-10 조회 4,157
14-07-08 조회 4,814
14-07-08 조회 4,282
14-07-05 조회 4,055
14-05-26 조회 5,451
14-05-26 조회 4,247
14-05-21 조회 4,564
14-05-19 조회 7,503
14-05-17 조회 6,946
14-04-30 조회 7,330
14-04-27 조회 4,776
14-04-26 조회 4,921
14-04-13 조회 4,916
14-04-13 조회 4,171
14-03-25 조회 6,496
14-03-25 조회 4,151
14-03-12 조회 4,030
14-03-12 조회 5,402
14-02-24 조회 4,712
13-12-27 조회 4,003
13-11-18 조회 4,325
13-11-18 조회 6,783
13-10-17 조회 4,819
13-10-03 조회 6,292
13-10-02 조회 4,201
13-09-29 조회 4,739
13-09-29 조회 4,047
13-09-17 조회 3,821
13-09-11 조회 6,247
13-09-09 조회 4,276
13-09-05 조회 9,546
13-08-23 조회 5,839
13-08-22 조회 5,367
13-08-22 조회 4,572
13-08-22 조회 5,086
13-08-17 조회 5,989
13-08-17 조회 4,332
13-07-11 조회 5,531
13-07-11 조회 4,470
13-07-08 조회 4,111
13-07-04 조회 4,257
13-07-04 조회 4,161
13-07-04 조회 4,039
13-07-03 조회 5,948
13-07-01 조회 3,798
13-07-01 조회 3,745
13-07-01 조회 4,613
13-06-21 조회 6,337
13-06-14 조회 4,861
13-06-11 조회 3,707
13-06-06 조회 5,442
13-06-05 조회 4,161
13-05-11 조회 4,929
13-05-10 조회 4,497
13-05-10 조회 4,686
13-05-10 조회 4,201
13-05-08 조회 4,420
13-05-08 조회 3,683
13-05-08 조회 4,102
13-05-08 조회 5,307
13-04-05 조회 6,071
13-03-31 조회 5,684
13-03-24 조회 4,046
13-03-24 조회 6,222
13-03-23 조회 3,723
13-03-21 조회 3,816
13-03-20 조회 3,783
13-03-20 조회 4,269
13-03-20 조회 3,823
13-03-20 조회 3,896
13-03-20 조회 6,075
13-03-20 조회 4,108
13-03-20 조회 4,753
13-03-19 조회 5,816
13-03-14 조회 3,966
13-03-14 조회 4,315
13-03-14 조회 4,585
13-03-08 조회 4,182
13-03-03 조회 4,588
13-02-24 조회 5,015
13-02-21 조회 4,814
13-02-19 조회 4,823