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

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

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

기능적으로 조금만 더 추가하면 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,193
11년 전 조회 2,079
11년 전 조회 2,411
11년 전 조회 1,089
11년 전 조회 2,921
11년 전 조회 3,109
11년 전 조회 1,638
11년 전 조회 2,302
11년 전 조회 1,164
11년 전 조회 1,498
11년 전 조회 1,176
11년 전 조회 2,372
11년 전 조회 2,284
11년 전 조회 1,268
11년 전 조회 5,400
11년 전 조회 2,439
11년 전 조회 3,167
11년 전 조회 2,012
11년 전 조회 1,057
11년 전 조회 2,124
11년 전 조회 2,262
11년 전 조회 1,970
11년 전 조회 1,581
11년 전 조회 1,062
11년 전 조회 1,942
11년 전 조회 2,667
11년 전 조회 1,387
11년 전 조회 2,881
11년 전 조회 1,839
11년 전 조회 4,588
11년 전 조회 1,953
11년 전 조회 2,604
11년 전 조회 3,821
11년 전 조회 1,695
11년 전 조회 2,553
11년 전 조회 913
11년 전 조회 1,947
11년 전 조회 4,584
11년 전 조회 1,710
11년 전 조회 1,975
11년 전 조회 852
11년 전 조회 1,259
11년 전 조회 1,564
11년 전 조회 1,687
11년 전 조회 1,574
11년 전 조회 2,336
11년 전 조회 1,258
11년 전 조회 3,174
11년 전 조회 3,367
11년 전 조회 1,932
11년 전 조회 4,853
11년 전 조회 9,992
11년 전 조회 2,729
11년 전 조회 1,209
11년 전 조회 3,353
11년 전 조회 2,674
11년 전 조회 2,201
11년 전 조회 1,118
11년 전 조회 4,341
11년 전 조회 802
11년 전 조회 1,330
11년 전 조회 1,768
11년 전 조회 1,985
11년 전 조회 1,957
11년 전 조회 4,721
11년 전 조회 1,710
11년 전 조회 944
11년 전 조회 2,126
11년 전 조회 1,703
11년 전 조회 2,709
11년 전 조회 973
11년 전 조회 1,656
11년 전 조회 1,564
11년 전 조회 1,705
11년 전 조회 1,315
11년 전 조회 1,272
11년 전 조회 1,324
11년 전 조회 1,674
11년 전 조회 1,738
11년 전 조회 1,846
11년 전 조회 1,750
11년 전 조회 2,028
11년 전 조회 1,240
11년 전 조회 1,443
11년 전 조회 1,407
11년 전 조회 1,555
11년 전 조회 2,062
11년 전 조회 1,626
11년 전 조회 1,625
11년 전 조회 6,072
11년 전 조회 1,677
11년 전 조회 1,823
11년 전 조회 1,868
11년 전 조회 1,973
11년 전 조회 2,364
11년 전 조회 3,948
11년 전 조회 2,350
11년 전 조회 1,124
11년 전 조회 904
11년 전 조회 1,052
🐛 버그신고