컴

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

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

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

기능적으로 조금만 더 추가하면 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건
+
제목 글쓴이 날짜 조회
15-12-13 조회 2,504
15-12-13 조회 2,918
15-12-11 조회 2,566
15-12-11 조회 2,530
15-12-11 조회 2,531
15-12-10 조회 2,487
15-12-10 조회 2,555
15-12-10 조회 2,525
15-12-03 조회 3,171
15-12-03 조회 2,691
15-11-25 조회 2,766
15-11-09 조회 3,013
15-11-04 조회 2,929
15-06-09 조회 4,047
15-05-06 조회 5,057
15-03-28 조회 4,507
14-12-05 조회 4,967
14-10-25 조회 4,979
14-10-13 조회 4,239
14-10-03 조회 6,099
14-09-19 조회 4,925
14-09-18 조회 4,008
14-09-13 조회 4,578
14-09-03 조회 5,552
14-08-26 조회 4,169
14-08-26 조회 3,955
14-08-26 조회 3,942
14-08-11 조회 6,369
14-08-06 조회 4,087
14-08-06 조회 3,681
14-08-06 조회 3,876
14-08-01 조회 6,207
14-08-01 조회 3,795
14-07-30 조회 4,391
14-06-28 조회 5,132
14-06-28 조회 4,409
14-05-11 조회 4,541
14-05-09 조회 4,903
14-05-09 조회 7,660
14-04-30 조회 4,226
14-04-27 조회 4,141
14-04-25 조회 4,868
14-04-21 조회 3,835
14-04-21 조회 4,963
14-04-10 조회 4,565
14-04-01 조회 6,130
14-03-03 조회 3,502
14-02-25 조회 5,887
14-02-14 조회 5,169
14-02-13 조회 4,924
14-01-03 조회 4,403
13-12-06 조회 3,744
13-11-22 조회 5,497
13-11-18 조회 3,998
13-10-02 조회 4,401
13-10-02 조회 3,666
13-10-02 조회 3,925
13-10-02 조회 3,789
13-10-02 조회 4,157
13-09-16 조회 8,003
13-09-16 조회 5,362
13-08-18 조회 5,365
13-07-11 조회 4,012
13-07-10 조회 4,646
13-07-09 조회 4,689
13-07-09 조회 4,945
13-07-04 조회 4,412
13-07-04 조회 4,074
13-07-04 조회 4,196
13-07-01 조회 4,686
13-07-01 조회 4,506
13-07-01 조회 6,727
13-06-23 조회 4,344
13-06-05 조회 3,599
13-05-29 조회 4,833
13-05-10 조회 4,244
13-04-05 조회 4,852
13-04-05 조회 6,542
13-04-05 조회 1.1만
13-04-05 조회 7,144
13-04-05 조회 6,537
13-03-31 조회 5,806
13-03-31 조회 4,126
13-03-28 조회 4,492
13-03-28 조회 6,658
13-03-28 조회 9,170
13-03-28 조회 4,302
13-03-24 조회 3,911
13-03-21 조회 4,586
13-03-21 조회 1.7만
13-03-14 조회 3,896
13-03-10 조회 4,702
13-03-10 조회 4,446
13-03-10 조회 4,156
13-03-08 조회 5,235
13-03-08 조회 4,343
13-03-03 조회 4,988
13-03-03 조회 7,431
13-03-03 조회 4,192
13-03-03 조회 1.1만