question 1:
i am trying to manipulate same classed div element’s css to their order with eq() but i cant access the eq() value.
question 2:
tried this with switch method. is there a way to do this progress with lesser code like for loop?
HTML
<div id="a" class="ele">0</div>
<div id="b" class="ele">1</div>
<div id="c" class="ele">2</div>
jQuery
$('.ele').each(function() {
var eleH = 100;
var add = 10;
$('.ele').eq(X); //trying to get value here
switch(X) {
case 0:
$('.ele').css({'height': (eleH + add) + 'px'}); // #a { height:110px}
break;
case 1:
$('.ele').css({'height': (eleH + (add*2)) + 'px'}); // #b { height:120px}
break;
case 2:
$('.ele').css({'height': (eleH + (add*3)) + 'px'}); // #c { height:130px}
break;
}
});
I’m not sure what do you want to do, but if you want to change CSS propierty according its position you can do it like this:
Here is the working version: http://jsfiddle.net/Aw39W/6/