我有这个 jQuery:
$(document).ready(function()
{
$("#panel").hide();
$('.login').toggle(
function()
{
$('#panel').animate({
height: "150",
padding:"20px 0",
backgroundColor:'#000000',
opacity:.8
}, 500);
},
function()
{
$('#panel').animate({
height: "0",
padding:"0px 0",
opacity:.2
}, 500);
});
});
这工作正常,但我需要稍微扩展一下功能。我还想以类似的方式与 #panel div 同步操作另一个 div 的属性。我尝试添加两个与辅助 div 相关的函数,但我只得到了 4 相切换...哈哈! 原谅我的无知!
谢谢大家!
最佳答案
$('.login').toggle(
function(){
$('#panel').animate({
height: "150",
padding:"20px 0",
backgroundColor:'#000000',
opacity:.8
}, 500);
$('#otherdiv').animate({
//otherdiv properties here
}, 500);
},
function(){
$('#panel').animate({
height: "0",
padding:"0px 0",
opacity:.2
}, 500);
$('#otherdiv').animate({
//otherdiv properties here
}, 500);
});
关于jQuery 切换动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/931113/