0
我有一个正常工作的jquery动画脚本,但是,我觉得有一种方法可以减少脚本的总体开销。这里是一个链接到网页发展:想要浓缩我的jquery动画脚本
http://dev.abinstallations.com
有两个部分的动画,这些动画应用到六个独立的div元素。一个单独的脚本应用于每个元素。例如:
//First
$("#first_flip").hide();
$("#first_button_show").click(function(){
$('#first_flip').animate({
opacity: 'toggle',
top: '+=524',
height: 'toggle'}, 600, function() {
// Animation complete.
});
});
$("#first_button_hide").click(function(){
$('#first_flip').animate({
opacity: 'toggle',
top: '-=524',
height: 'toggle'}, 400, function() {
// Animation complete.
});
});
//Second
$("#second_flip").hide();
$("#second_button_show").click(function(){
$('#second_flip').animate({
opacity: 'toggle',
top: '+=524',
height: 'toggle'}, 600, function() {
// Animation complete.
});
});
$("#second_button_hide").click(function(){
$('#second_flip').animate({
opacity: 'toggle',
top: '-=524',
height: 'toggle'}, 400, function() {
// Animation complete.
});
});
...等等其余四个元素。有没有一种凝聚的方式来实现这一目标?
你发布的链接已经死了..因为所有按钮的代码都是相同的,所以它应该能够将它浓缩到一个单独的发生,但是我们需要首先看到html .. – 2010-11-02 17:52:10
Gaby - 谢谢你的发现。新的链接是dev.abinstallationsinc.com – David 2010-11-17 02:23:49