다음과 같은 기능이 있습니다. jQuery : slideDown jump
function notificationBoxOutput(type, message) {
if (type == "success") { $('.notificationBox').removeClass('warning').addClass('success'); }
if (type == "warning") { $('.notificationBox').removeClass('success').addClass('warning'); }
$('.notificationBox').html('<b>' + type + ':</b> ' + message);
$('.notificationBox').slideDown().delay(3000).slideUp();
}
다음과 같은 CSS 기능이 정상에서 notificationBox해야 slideDown을 해고 그래서
div.notificationBox
{
top: 0px;
left: 0px;
width: 100%;
position: fixed;
z-index: 3;
background: #333333;
text-align: center;
vertical-align: center;
opacity:0.85;
filter:alpha(opacity=85);
display: none;
}
div.warning { background-color: #990000; display: block; }
div.success { background: #009900; display: block; }
는 그 메시지 3secs slideUp 후 다시을 보여줍니다.
slideUp 만 애니메이션으로 잘 작동하지만 slideDown이 애니메이션없이 점프하는 이유는 무엇입니까?
이것은 오프 토픽이지만 : *** *** ($. 'notificationBox')'를 할 때마다 jQuery는 DOM을 위에서 아래로 검색해야한다. 함수를 반복적으로 호출하는 것이 아니라 * 한 번 호출 *하여 결과를 변수에 저장하고이를 사용합니다. –
내 대답 – avall