点击jQuery后重置样式

时间:2013-06-19 11:09:05

标签: jquery

在jQuery中单击面板后,我需要帮助重置样式

$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
$("#wrapper").css("height","900px");
$("#wrapper").css("background-size","… 700px");
});

我如何将div(包装器)重置为原始样式:

$("#wrapper").css("height","600px");
$("#wrapper").css("background-size","4… 500px");

请帮帮我!!

2 个答案:

答案 0 :(得分:1)

像这样创建css:

.original{
     height:"600px";
     background-size:"500px";
}
.temp{
     height:"900px";
     background-size:"700px";
}

添加,删除或切换类以更改样式:

$("#wrapper").toggleClass('original temp')

答案 1 :(得分:0)

Place your default style for the div immediately after ready function before click event.

$(document).ready(function(){
$("#wrapper").css("height","600px");
$("#wrapper").css("background-size","4… 500px");

$("#flip").click(function(){
$("#panel").slideToggle("slow");
$("#wrapper").css("height","900px");
$("#wrapper").css("background-size","… 700px");
});