arrays - Can JavaScript data be attached to HTML elements? -


i have array (below)

var img_name = new array("images/test.jpg", "images/test.jpg"); var imgtotal = img_name.length; var rnd_no = math.floor(imgtotal*math.random()); var ojimg = img_name[rnd_no]; 

what need pass piece of information , attach body tag. so. if test1.jpg loaded need pass "light" body tag , if other image selected need pass "dark". alows user in cms select light or dark theme depending on image. image output randomly.

how nested arrays:

var img_name = [["images/test1.jpg", "light"], ["images/test2.jpg", "dark"]]]; var imgtotal = img_name.length; var rnd_no = math.floor(imgtotal*math.random()); var ojimg = img_name[rnd_no][0]; var cssclass = img_name[rnd_no][1]; 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -