컴

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

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

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

기능적으로 조금만 더 추가하면 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-03-24 조회 3,483
14-03-24 조회 3,324
14-03-23 조회 7,826
14-03-22 조회 3,242
14-03-21 조회 3,284
14-03-20 조회 5,716
14-03-19 조회 3,572
14-03-19 조회 7,287
14-03-19 조회 4,617
14-03-18 조회 5,404
14-03-18 조회 3,155
14-03-17 조회 3,235
14-03-17 조회 4,073
14-03-17 조회 3,222
14-03-17 조회 4,218
14-03-17 조회 4,159
14-03-17 조회 7,209
14-03-16 조회 3,697
14-03-16 조회 4,705
14-03-16 조회 3,939
14-03-15 조회 4,010
14-03-15 조회 4,087
14-03-15 조회 3,580
14-03-15 조회 4,180
14-03-15 조회 2,965
14-03-14 조회 6,571
14-03-14 조회 4,424
14-03-14 조회 4,214
14-03-13 조회 3,812
14-03-13 조회 9,350
14-03-13 조회 3,715
14-03-13 조회 3,423
14-03-13 조회 5,107
14-03-13 조회 4,246
14-03-13 조회 3,372
14-03-12 조회 3,869
14-03-12 조회 5,076
14-03-12 조회 4,522
14-03-12 조회 4,342
14-03-12 조회 4,732
14-03-12 조회 4,883
14-03-12 조회 5,838
14-03-12 조회 5,288
14-03-11 조회 5,407
14-03-11 조회 6,114
14-03-11 조회 5,953
14-03-11 조회 3,160
14-03-11 조회 6,749
14-03-11 조회 7,853
14-03-10 조회 3,454
14-03-08 조회 4,664
14-03-07 조회 3,833
14-03-07 조회 3,136
14-03-06 조회 3,573
14-03-06 조회 3,134
14-03-05 조회 5,358
14-03-04 조회 4,125
14-03-04 조회 3,152
14-03-04 조회 3,213
14-03-04 조회 3,593
14-03-03 조회 3,363
14-03-03 조회 3,271
14-03-02 조회 3,166
14-03-02 조회 3,206
14-02-28 조회 3,170
14-02-26 조회 3,169
14-02-26 조회 3,167
14-02-25 조회 3,210
14-02-25 조회 5,734
14-02-24 조회 3,566
14-02-24 조회 2,824
14-02-24 조회 2,851
14-02-24 조회 4,586
14-02-23 조회 3,679
14-02-20 조회 3,232
14-02-20 조회 2,888
14-02-20 조회 3,310
14-02-20 조회 2,912
14-02-18 조회 3,865
14-02-17 조회 3,323
14-02-17 조회 2,797
14-02-17 조회 3,020
14-02-17 조회 3,992
14-02-17 조회 3,832
14-02-17 조회 3,409
14-02-15 조회 2,789
14-02-14 조회 3,362
14-02-14 조회 2,748
14-02-14 조회 4,976
14-02-14 조회 3,671
14-02-14 조회 3,697
14-02-14 조회 2,924
14-02-14 조회 2,695
14-02-14 조회 5,017
14-02-14 조회 3,230
14-02-14 조회 2,700
14-02-14 조회 5,012
14-02-13 조회 2,871
14-02-13 조회 4,623
14-02-12 조회 5,583