Reference string as object
- by xintron
I've got the following function that manipulates an element according to the data being sent (an object).
function manipulateElem (elem, data) {
for (var key in data) {
elem[key] = data[key];
};
}
manipulateElem(document.getElementById('test'), {'href': '/home/', 'style.color': '#000000'});
As you can imagine, the later (style.color) doesn't work. How would one solve this the best way?