请问,为什么这不起作用:
$("#togglePanel").click(function(e){
$("#toolpanel").toggle(function(){
$("#orderMap").animate({marginLeft: 0, width: "100%"}, 500);
}, function(){
$("#orderMap").animate({marginLeft: "341px", width: "576px"}, 500);
});
});
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,它的工作原理是:
$("#togglePanel").click(function(e){
$("#toolpanel").toggle(function(){
$("#orderMap").animate({marginLeft: 0, width: "100%"}, 500);
});
});
Run Code Online (Sandbox Code Playgroud)
谢谢...
该toggle函数"在内部使用click事件".也就是说,它将函数绑定到单击事件,因此您也不需要调用click.试试这个:
$("#togglePanel").toggle(function(){
$("#orderMap").animate({marginLeft: 0, width: "100%"}, 500);
}, function(){
$("#orderMap").animate({marginLeft: "341px", width: "576px"}, 500);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
492 次 |
| 最近记录: |