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(){
#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;'>
</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>
</div>
답변 4
#billboardButton {
..............
display: none; <----- 추가요
}
// $('#billboard').show();
제가 위에 넣은 저것이 눈에 않 보이게 하는 부분이구요
자체에 넣으시면 않되요....
지금보니 현재 글에 더보기 기능을 추가 하셨네요...^-^
if(cook=='false') {
=> if(cook != 'true') {
답변을 작성하시기 전에 로그인 해주세요.