0

在 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");

可以帮帮我吗!!

4

2 回答 2

1

像这样创建css:

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

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

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

于 2013-06-19T11:12:38.207 回答
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");
});
于 2013-06-19T11:11:58.360 回答