Jump to content

styles using an object list


The Little Guy

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.