javascript - Change div's width by a value in JS -


how change div's width value, this:

somediv.style.width += "100px"; 

it works when want set value (i.e. width = "100px") problem += operator.

this work vanilla javascript solution (since didn't mention jquery):

var somediv = document.getelementbyid("somediv"); var w = 0; if (typeof somediv.clip !== "undefined") {     w = somediv.clip.width; } else {     if (somediv.style.pixelwidth) {         w = somediv.style.pixelwidth;     } else {         w = somediv.offsetwidth;     } } somediv.style.width = (w + 100) + "px"; 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -