The Little Guy Posted July 31, 2012 Share Posted July 31, 2012 I am Not sure why this isn't working, but I might have an idea why it isn't, but that won't help me fix the issue. The issue is when I go through the "for" loop, none of the styles are being applied. My best guess is that it is trying to apply "i" and not the actual value. What can I do to get it to work? var elem = document.getElementById("append"); var css = { color: "red", fontSize: "12px" }; for(var i in css){ elem.style.i = css[i]; } Link to comment https://forums.phpfreaks.com/topic/266515-styles-using-an-object-list/ Share on other sites More sharing options...
The Little Guy Posted July 31, 2012 Author Share Posted July 31, 2012 Just had to do this: elem.style[i] = css[i]; I believe it is called array notation. Link to comment https://forums.phpfreaks.com/topic/266515-styles-using-an-object-list/#findComment-1365792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.