jQuery attribute question
- by Nick Simone
I'm trying to select a series of divs one at a time. I'm sure theres a better way to do this, but I gave them all unique rels and I'm using the rels to select them one at a time. I want to move them over the width of the div, then animate it dropping down the screen. What I have is:
$(document).ready(function(){
var totalbricks = 7;
var index = 2;
$(".brick").animate({top:"600px"});
while(index < totalbricks)
{
var postion = 45*index;
$(".brick[rel='+index+']").css('left', postion+'px');
$(".brick[rel='+index+']").animate({top:"600px"});
index++;
}
});
All the divs are in a container div.
Jquery docs say, 'Variables can be used using the following syntax: [name='" +MyVar+ "']'
What am I doing wrong?
Here is the HTML that is being used by the jQuery
<body>
<div id="container">
<div id="canvas">
<div class="brick" rel="1">
</div>
<div class="brick" rel="2">
</div>
<div class="brick" rel="3">
</div>
<div class="brick" rel="4">
</div>
<div class="brick" rel="5">
</div>
<div class="brick" rel="6">
</div>
<div class="brick" rel="7">
</div>
</div>
</div>
</body>