javascript - Using range slider to change div height -


seen examples using range input control rotation of div javascript, cant see how change other properties such height , opacity. here example:

function rotate(value) { x=document.getelementbyid('div1') x.style.webkittransform="rotate(" + value + "deg)";  }   <input type="range" min="0" max="360" value="0" onchange="rotate(this.value)"> 

thanks help.

for more generalized solution, can create generic setstyleon method. jsfiddle

js:

function setstyleon(rule, targetid, value) {     x = document.getelementbyid(targetid);     x.style[rule] = value; } 

html:

<label>rotation</label> <input type="range" min="0" max="360" value="0"      onchange="setstyleon('webkittransform', 'div1', 'rotate(' + this.value + 'deg')"> <label>opacity</label> <input type='range' min='0' max='1.0' value='1.0' step='0.1'      onchange="setstyleon('opacity', 'div1', this.value)" /> <label>height</label> <input type='range' min='0' max='100' value='10' step='1'      onchange="setstyleon('height', 'div1', this.value + 'em')" />     <label>width</label> <input type='range' min='0' max='100' value='10' step='1'      onchange="setstyleon('width', 'div1', this.value + 'em')" />     <div id="div1"> </div> 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -