Kev*_*own 26 jquery animation toggle
我有这个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);
});
});
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我需要扩展功能.我也希望同样操作另一个div的属性与#panel div同步.我尝试添加两个与辅助div相关的功能,但我只是进行了4阶段切换......哈哈!原谅我的无知!
多谢你们!
Vin*_*nie 50
$('.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);
});
Run Code Online (Sandbox Code Playgroud)
小智 6
我不认为在切换功能中添加双重功能适用于已注册的点击事件(除非我遗漏了某些内容)
例如:
$('.btnName').click(function() {
top.$('#panel').toggle(function() {
$(this).animate({
// style change
}, 500);
},
function() {
$(this).animate({
// style change back
}, 500);
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
134313 次 |
最近记录: |