slideToggle 사용할때 닫힘을 먼저 보여주려면?

slideToggle 사용할때 닫힘을 먼저 보여주려면?

QA

slideToggle 사용할때 닫힘을 먼저 보여주려면?

본문

아래는 쿠키로 기억하는 slideToggle 인데요.
처음 보여줄때 열린 상태에서 시작하는데요.
이것을 닫힌 상태에서 시작하려면 어떻게해야 되나요?
도움 부탁 드립니다.ㅜㅜ
 
<style>
#billboardButton {
    background-color:#f1f1f1;
    background-image:url(<?=$g4['path']?>/images/close2.gif);
    color:#666;
    padding:0px;
    width:1220px;
    height:13px;
    cursor:pointer;
    text-align:center;
    margin:0 auto;
}
</style>
</head>
<body>
<script>
$(document).ready(function(){

    if($.cookie('billboardStatus')) {
        var cook = $.cookie('billboardStatus');
    } else {
        var cook = $.cookie('billboardStatus', 'true', {expires: 1});
    }
    //var cook= $.cookie('billboardStatus');
    if(cook=='false') {
        $('#billboard').hide();
        $("#billboardButton").css("background-image", "url(<?=$g4['path']?>/images/open2.gif)").text('');
    } else {
    $('#billboard').show();
        $("#billboardButton").text('');
    }
    $('#billboardButton').on('click', function() {
        $('#billboard').stop().slideToggle(300, function(){
            $("#billboardButton").css("background-image", $(this).is(':not(:visible)') ? "url(<?=$g4['path']?>/images/open2.gif)" : "").text($(this).is(':visible') ? '' : '');
            $.cookie('billboardStatus', $(this).is(':visible'), {expires:1});
        });
    });
}); // End document ready
</script>
<div id="test" style="width:1220px;margin:3px auto;">
    <div id="billboardButton"></div>
    <div id='billboard' style='width:1220px; height:190px;display:none;'>
내용
</div>

이 질문에 댓글 쓰기 :

답변 4

#billboardButton {
    ..............
    display: none;    <----- 추가요
}

답변 감사 드립니다.
말씀하신대로 해봤는데, 안되는 것 같아요.ㅜㅜ
display: none; 을 추가 했더니, 버튼이 사라져 버렸어요.
이렇게 넣으라는 말씀이 맞으시죠?
<style>
#billboardButton {
    background-color:#f1f1f1;
    background-image:url(<?=$g4['path']?>/images/close2.gif);
    color:#666;
    padding:0px;
    width:1220px;
    height:13px;
    cursor:pointer;
    text-align:center;
    margin:0 auto;
    display: none;
}
</style>
어떻게 할 방법이 없을까요?

// $('#billboard').show(); 
제가 위에 넣은 저것이 눈에 않 보이게 하는 부분이구요
자체에 넣으시면 않되요....

지금보니 현재 글에 더보기 기능을 추가 하셨네요...^-^
if(cook=='false') {
=> if(cook != 'true') {
답변을 작성하시기 전에 로그인 해주세요.
전체 345
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT