특정 조건에 Button 숨기기, 보이기 - hide(), show()

 

$(function(){

    $("#toggle_id").bind("click", function(){

        if($("#toggle_id").val()==0){

            $("#toggle_id").val(1); 

        }

        else{

            $("#toggle_id").val(0);

        }

        

        var isHide=$("#toggle_id").val();

        if(isHide==1){

            // Button 숨기기

            $("#admin_id").hide();

        }

        else{

            // Button 보이기

            $("#admin_id").show();

        }

    });

});

 

<body>

...

<button id="admin_id">관리자</button>

<button id="toggle_id" value="0">버튼 토글</button>

...

</body>

 

+ Recent posts