Javascript - How to get all elements and do same thing on each of them -


i want divs in div(id = room) , same javascript code on each one.

i think should this

get element id room -> divs inside -> on them(change each class "grass")

or using loop.

how that?

please don't use jquery.

modern browsers (ie9+):

var divs = document.queryselectorall('#room div');  [].foreach.call(divs, function(div){   div.classname = 'green'; }); 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -