0
我有一个问题,我设法得到一些代码,使div元素滑入视图,但我怎么会让它再次滑下来,如果关闭按钮已被点击?这样我就可以继续按下链接,它会再次播放动画,而不是只显示div在最终位置。我如何动画我的div滑出按钮单击
继承人的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 2012-01-18 18:09:26
@贾斯珀是的,对不起,你走了。它的意思是一个模式窗口弹出窗口,但它似乎无法正常工作在jsfiddle虽然由于某种原因(对于我来说)http://jsfiddle.net/4hw8H/ – Farreal 2012-01-18 18:15:20
你的jsfiddle需要包括jQuery(你这样做在左边NAV-面板)。我在下面的答案中发布了更新到你的jsfiddle。 – Jasper 2012-01-18 18:31:05