Search code examples
javascripthtmloffsetchildren

Div Wrapper childern setArribute offset


I am adding a wrapper to a division and trying to set offset right as follow:

                var wrapper_div = document.getElementById('container1');
                var kinetic_div = wrapper_div.children[0];
                canvaso = kinetic_div.children[0];
                canvaso.setAttribute('id', "panel1");
                canvaso.setAttribute('offset', '100px');

Unfortunately it does not work! Would appreciate your suggestions.


Solution

  • Do this:

    canvaso.style.offset = '100px;' 
    

    or

    canvaso.setAttribute('style','offset:100px;');
    

    I presume that you are trying to change the style.