0
문제가 생겼습니다. div 요소를 슬라이드로 위로 올려 놓을 수있는 코드를 얻을 수 있었지만 닫기 버튼이 있으면 다시 슬라이드하는 방법은 무엇입니까? 클릭 했습니까? 그래서 나는 링크를 계속 누를 수 있고 그것은 최종 위치에있는 div를 단지 보여주는 대신에 애니메이션을 다시 재생할 것입니다. 버튼을 클릭 할 때 내 div를 움직이게하려면 어떻게해야합니까?
을 heres jQuery 코드$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(600);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//Slide up Boxes Div transition effect
$(id).css({display:'block'}).animate({marginTop:'0px', opacity:'1', },400);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function() {
$(this).hide();
$('.window').hide();
});
});
감사
HTML을 게시하거나 코드의 jsfiddle을 만들 수 있습니까? – Jasper
@ 재 스퍼 예, 죄송합니다. 여기에 있습니다. 그것의 모달 윈도우 팝업 될 것이었지만 그것은 나던을 위해 (비록 어쨌든) jsfiddle에서 제대로 작동하는 것 같지 않습니다 http://jsfiddle.net/4hw8H/ – Farreal
jsfiddle jQuery를 포함해야했습니다 (당신은 왼쪽에서 탐색 패널). 내 대답은 아래 jsfiddle에 대한 업데이트를 게시했습니다. – Jasper