컴

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

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

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

기능적으로 조금만 더 추가하면 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건
+
제목 글쓴이 날짜 조회
12-08-29 조회 4,188
12-08-07 조회 3,846
12-08-03 조회 3,657
12-07-31 조회 3,760
12-07-30 조회 3,712
12-07-16 조회 3,916
12-07-15 조회 3,749
12-07-07 조회 3,607
12-07-06 조회 3,809
12-07-03 조회 3,766
12-06-29 조회 3,384
12-06-22 조회 3,757
12-06-17 조회 4,017
12-05-21 조회 3,941
12-05-02 조회 3,460
12-05-02 조회 4,252
12-05-02 조회 3,373
12-04-30 조회 3,571
12-04-30 조회 3,257
12-03-17 조회 4,126
12-03-10 조회 3,455
12-03-08 조회 3,978
12-03-03 조회 3,690
12-02-27 조회 5,107
12-02-17 조회 4,400
12-02-16 조회 4,680
12-02-03 조회 3,345
12-01-31 조회 3,254
12-01-24 조회 3,256
12-01-17 조회 3,958
12-01-05 조회 3,501
11-12-30 조회 3,234
11-12-23 조회 4,787
11-12-08 조회 3,557
11-12-07 조회 4,516
11-11-27 조회 3,947
11-11-25 조회 4,274
11-11-23 조회 3,716
11-11-22 조회 3,574
11-11-09 조회 3,282
11-10-23 조회 3,220
11-10-19 조회 3,181
11-10-08 조회 2,865
11-10-04 조회 2,862
11-10-04 조회 5,321
11-09-01 조회 4,397
11-08-13 조회 2,570
11-08-06 조회 3,255
11-07-11 조회 3,649
11-06-27 조회 3,008
11-06-21 조회 2,675
11-06-13 조회 2,480
11-06-07 조회 2,489
11-05-26 조회 2,445
11-04-20 조회 2,777
11-03-21 조회 2,876
11-03-18 조회 2,568
11-03-11 조회 2,584
11-02-07 조회 2,412
11-01-18 조회 2,736
11-01-12 조회 2,459
11-01-06 조회 2,549
10-12-10 조회 2,808
10-12-09 조회 2,661
10-12-08 조회 5,093
10-11-29 조회 2,927
10-11-28 조회 2,830
10-11-28 조회 2,663
10-11-19 조회 2,857
10-11-04 조회 2,731
10-10-21 조회 2,457
10-10-19 조회 3,416
10-10-12 조회 2,740
10-10-07 조회 2,574
10-09-30 조회 3,530
10-09-17 조회 3,946
10-09-17 조회 3,888
10-05-31 조회 3,597
09-12-31 조회 3,733
09-07-23 조회 5,058
08-09-16 조회 3,257
08-09-06 조회 3,002
08-09-04 조회 3,426
08-08-16 조회 4,452
08-08-15 조회 3,320
08-08-14 조회 4,534
08-08-12 조회 4,004
08-07-23 조회 2,820
08-07-10 조회 3,769
08-07-04 조회 2,998
08-06-27 조회 7,634
08-06-19 조회 4,948
08-05-27 조회 5,553
08-05-25 조회 5,386
08-05-23 조회 3,467
08-05-23 조회 4,633
08-05-21 조회 4,979
08-05-20 조회 4,093
08-05-20 조회 3,317
08-04-18 조회 4,392