2013-03-17 60 views
0

我想創建一個jquery腳本來旋轉每個div 15 * x度,但它不會工作。我發現了w3schools的css旋轉代碼,實際上它是從樣式表中工作的。jQuery旋轉幾個div for循環

反正我使用的代碼:

$(function() { 
    var nrOfDivs = $(this).length(); 
    for(x=0; x=nrOfDivs; x++) { 
     var y = x * 15; 
     var wheelSpin = { 
      'transform' : 'rotate(' + y + ')', 
      '-ms-transform' : 'rotate(' + y + ')', 
      '-moz-transform' : 'rotate(' + y + ')', 
      '-webkit-transform' : 'rotate(' + y + ')', 
      '-o-transform' : 'rotate(' + y + ')' 
     } 
     $('.wheelbox').each(function() { 
      $(this).css(wheelSpin); 
     }); 
    } 
}); 

我在做什麼錯在jQuery的?

回答

0

你的循環是錯誤的

for(x=0; x=nrOfDivs; x++) 


應該x < nrOfDivs或whaever布爾是siutable。

肯定x=nrOfDivs不好

+1

謝謝!我覺得我很累,不承認那個! – 2013-03-17 20:47:57

+0

是的,我知道你的意思 – kidwon 2013-03-17 20:50:56