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

· 11년 전 · 1988
아래 소스는 제가 퍼블리싱 하면서 만들었던 레이어 셀렉트 박스 소스인데요.

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

기능적으로 조금만 더 추가하면 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);
    //////////////////////////////////////////////////////////////////////////////////////////////
});
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

프로그램

+
제목 글쓴이 날짜 조회
11년 전 조회 1,232
11년 전 조회 2,117
11년 전 조회 2,453
11년 전 조회 1,124
11년 전 조회 2,978
11년 전 조회 3,149
11년 전 조회 1,688
11년 전 조회 2,356
11년 전 조회 1,213
11년 전 조회 1,543
11년 전 조회 1,224
11년 전 조회 2,430
11년 전 조회 2,331
11년 전 조회 1,318
11년 전 조회 5,451
11년 전 조회 2,495
11년 전 조회 3,221
11년 전 조회 2,069
11년 전 조회 1,111
11년 전 조회 2,177
11년 전 조회 2,310
11년 전 조회 2,026
11년 전 조회 1,621
11년 전 조회 1,115
11년 전 조회 1,991
11년 전 조회 2,724
11년 전 조회 1,452
11년 전 조회 2,939
11년 전 조회 1,891
11년 전 조회 4,637
11년 전 조회 2,004
11년 전 조회 2,662
11년 전 조회 3,875
11년 전 조회 1,747
11년 전 조회 2,605
11년 전 조회 976
11년 전 조회 2,006
11년 전 조회 4,634
11년 전 조회 1,771
11년 전 조회 2,025
11년 전 조회 909
11년 전 조회 1,312
11년 전 조회 1,617
11년 전 조회 1,747
11년 전 조회 1,627
11년 전 조회 2,392
11년 전 조회 1,313
11년 전 조회 3,237
11년 전 조회 3,420
11년 전 조회 1,989
11년 전 조회 4,915
11년 전 조회 1만
11년 전 조회 2,792
11년 전 조회 1,271
11년 전 조회 3,402
11년 전 조회 2,729
11년 전 조회 2,261
11년 전 조회 1,175
11년 전 조회 4,397
11년 전 조회 866
11년 전 조회 1,376
11년 전 조회 1,827
11년 전 조회 2,045
11년 전 조회 2,018
11년 전 조회 4,779
11년 전 조회 1,774
11년 전 조회 1,006
11년 전 조회 2,193
11년 전 조회 1,760
11년 전 조회 2,756
11년 전 조회 1,019
11년 전 조회 1,711
11년 전 조회 1,618
11년 전 조회 1,749
11년 전 조회 1,387
11년 전 조회 1,329
11년 전 조회 1,385
11년 전 조회 1,738
11년 전 조회 1,799
11년 전 조회 1,903
11년 전 조회 1,798
11년 전 조회 2,094
11년 전 조회 1,305
11년 전 조회 1,508
11년 전 조회 1,454
11년 전 조회 1,618
11년 전 조회 2,123
11년 전 조회 1,679
11년 전 조회 1,683
11년 전 조회 6,129
11년 전 조회 1,742
11년 전 조회 1,875
11년 전 조회 1,916
11년 전 조회 2,026
11년 전 조회 2,426
11년 전 조회 4,006
11년 전 조회 2,413
11년 전 조회 1,181
11년 전 조회 968
11년 전 조회 1,117
🐛 버그신고