addclass - jQuery, 960.gs - Apply 'alpha' and 'omega' classes to every 1st and 4th div -


i creating layout using 960 grid system , have div items displayed automatically. need able apply 'alpha' class first , 'omega' class fourth e.g. div-alpha,div,div,div-omega,div-alpha,div,div,div-omega.

using code below applying alpha class of divs :

var n = $("div.item").length;      $('div .item').filter(function(index) {     return n % 5 == 1;         }).addclass('alpha');          $('div .item').filter(function(index) {     return n % 5 == 5;         }).addclass('omega'); 

how can achieve this? many in advance.

you do:

var divs = $("div.item"); var length = divs.length divs.eq(3).addclass('omega'); divs.eq(0).addclass('alfa'); divs.eq(length-1).addclass('omega'); 

if there container contains divs use nth-child() selector


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -