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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -