重置更改的CSS值 [英] reset changed css values

查看:83
本文介绍了重置更改的CSS值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有...

$("#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);
});

但是我想说的是,当单击第二个功能时,应重置第一个更改的所有css.这意味着以下行是错误的:

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...

推荐答案

$('.page').css({"width":"", "height":"", "top": "", "left" : ""});

应该为你做魔术.

这篇关于重置更改的CSS值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆