Reference string as object

Posted by xintron on Stack Overflow See other posts from Stack Overflow or by xintron
Published on 2010-05-07T22:02:20Z Indexed on 2010/05/07 22:08 UTC
Read the original article Hit count: 93

Filed under:

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?

© Stack Overflow or respective owner

Related posts about JavaScript