javascript - How to use variables in DOM CSS -


i want make webpage responsive using javascript. can tell me why doesn't work , how should this?

document.getelementbyid("id1").style.left = variable; 

very hard understand asking created fiddle passing variable show syntax. https://jsfiddle.net/b6clt0td/1/

<div id="id1">  </div> <input type="button" value="click me" onclick="somefunc()"/> <input type="button" value="move me" onclick="movefunc()"/> <script> function somefunc(){ var red ="red";  document.getelementbyid("id1").style.backgroundcolor = red; } function movefunc(){ var dist = 100;  document.getelementbyid("id1").style.left = dist +"px"; } </script> 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -