jquery selecting previous or next element among the matched elements -


i have set of divs in first div has width , height. need selecting divs , set it's width , height adding 50 px previous div. example, if 1st 1 100px width , 75 height, second div should 150px x 125 , next 1 200x175 , on. in jquery, used $("div").each(....) go through elements ... need retrieve width , height of previous selected element(not previous sibling!) me it......... thanks

why not this:

var previousheight = 75; var previouswidth = 100; $("div").each(function () {   $(this).height(previousheight);   $(this).width(previouswidth);   previousheight += 50;   previouswidth += 50; }); 

no need have previous div if keeping track of previous height. thought!

jsfiddle - quick example put jsfiddle code: http://jsfiddle.net/mftqa/


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -