Problem with animate elements with for loop using next()
I want to change background-color (whatever) for each of
test_div when
test_div_main is clicked. I want to do this in loop because in future i want to set color depended on
i value in to loop.
This is clear html code:
- <div class="test_div_main">1</div>
- <div class="test_div">2</div>
- <div class="test_div">3</div>
- <div class="test_div">4</div>
- <div class="test_div">5</div>
- <div class="test_div">6</div>
- <div class="test_div">7</div>
and this is jQ code:
- $(document).ready(function(){
- var numItems = $('.test_div').length;
- $('.test_div_main').click(function(){
- var next_div = $('.test_div_main').next('.test_div');
- for (var i = 0; i > numItems; i++)
- {
- next_div.css({
- "background-color": "yellow"
- });
- next_div = next_div.next('.test_div')
- }
- });
- });
Can You find reason why it's not working? Or maybe there is better way than mine?