javascript - Add class with a particular div -



javascript - Add class with a particular div -

i have div

<div class="newdiv">

it generating in loop, like

<div class="newdiv"> <div class = "innerdiv"> somecode </div> </div> <div class="newdiv"> <div class = "innerdiv"> somecode </div> </div> <div class="newdiv"> <div class = "innerdiv"> somecode </div> </div>

now want add together class "brightdiv" div generated @ odd places like

with first , 3rd div.

what should add together class "brightdiv" along "newdiv" every div @ odd place?

try : can utilize :odd or :even select odd / elements, depend on index position , not natural number count. in case, want first , 3rd position div i.e. index= 0 , 2 index position , hence utilize :even.

$('div.newdiv:even').addclass('brightdiv');

demo

javascript jquery html css jsp

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -