I've got...
$("#menu_tl").click(function() {
$('.page').fadeOut();
$('.page').animate({
"width": "0px",
"height": "0px",
"top": "50px",
"left": "50px"
});
$('#page1').fadeIn();
$('#page1').animate({
"width": "500px",
"height": "400px",
"top": "-350px",
"left": "-450px"
}, 2000);
});
$("#menu_tr").click(function() {
$('.page').fadeOut();
$('.page').animate({
"width": "0px",
"height": "0px",
"top": "50px",
"left": "50px"
});
$('#page2').fadeIn();
$('#page2').animate({
"width": "500px",
"height": "400px"
}, 2000);
});
But I want to say that when the second function is clicked all altered css by the first one should be reset. This means that the following line is wrong:
$('.page').animate({
"width": "0px",
"height": "0px",
"top": "50px",
"left": "50px"
});
is wrong and should be replaced by a global reset. Hope this is clear enough...
This
$('.page').css({"width":"", "height":"", "top": "", "left" : ""});
should do the magic for you.
Store the initial css values you will be changing in a variable:
var $page = $('.page'),
initialCss = {
width: $page.css('width'),
height: $page.css('height'),
// Could also be .css('top'), .css(left')
// depends on your initial stylesheet
top: $page.position().top + 'px',
left: $page.position().left + 'px'
};
$("#menu_tr").click(function(){
$page.animate( initialCss, 2000 );
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With