Code:

function razvorot(num) { var w = 50; var w2 = 50; if (num = 1) { while (w < 100) { w++; w2--; document.getElementById('kortush').width = w + '%'; document.getElementById('kandi').width = w2 + '%'; console.log('mod1:w = ' + w + '; w2 = ' + w2); } } else { while (w < 100) { w++; w2--; document.getElementById('kandi').width = w + '%'; document.getElementById('kortush').width = w2 + '%'; console.log('mod2:w = ' + w + '; w2 = ' + w2); } } } 

The console displays everything as it should. But the #kandi and #kortush elements themselves do not change. In chrome, I look at the code. Really nothing has changed. And so in every browser! How to fix?



    1 answer 1

    To change the styles of elements, you need to operate with the style property:

     document.getElementById(ID).style.width = '100px'; 

    Be sure to indicate in what format you are inserting numbers (px, em,%, etc)