changing css property relative to eq().. jQuery/JavaScript

tixdugenligue

New Member
i am trying to change the 'left' property of a group of divs dependant on their eq() value. i will show a basic code of what i'm trying to do! any help will be appreciatedHTML:\[code\]<html><body><div class"item-holder"></div> <div class"item item-one"></div> <div class"item item-one"></div> <div class"item item-one"></div> <div class"item item-one"></div></div></body></html>\[/code\]CSS:\[code\].item-holder {position:relative;width:100px;}.item {position:absolute;width:25px;float:left;}\[/code\]jQuery:\[code\]$(document).ready(){var itemWidth = $('.item-holder').width()/$('.item').size(); $('.item').css({ 'left':$('.this').eq()*itemWidth+'px' });};\[/code\]please not this is not the full code i can post it if it makes more sense, the reason i need the left value to be created in jQuery is because i'd like to reuse this code in several different places and will use a different number of 'items' each time! any help is welcomed and taken onboard
 
Back
Top