0

我试图让下面的函数循环遍历一个 div 列表 - 到目前为止,我只将它设置为应用于一个 div (#two) 和最近的 div。我知道它需要增加 (i+++),其中第一个 div (#one) 将具有 i=0。

是的,我是那个建立自己的裸骨滑块的新人。

function movedown() {
   $("#two").next().animate({height:'80%'}, 500);
   $("#two").animate({height: '20px'},500);
;}

function moveup() {     
   $("#two").prev().animate({height:'80%'}, 500);
   $("#two").animate({height: '20px'},500);
;}

$(function () {
   $('#up').click(moveup); 
   $('#down').click(movedown);
}); 
4

1 回答 1

1

当你现在正在做仪式时,给你的 div id 像一二三。然后尝试这可能会有所帮助

function movedown() {
    for(var i=0; i<(no of divs);i++){
        $("#"+i).next().animate({height:'80%'}, 500);
        $("#"+i).animate({height: '20px'},500);
    }
 ;}
于 2012-05-23T12:30:11.093 回答