jquery - Get range input value to css using Javascript -


i did code simple css process bar. need range or textbox value div width <div style="width:50%;">, when user change value of range or textbox textbox takes range value in code. can using javascript? *i'm not js no idea how start! possible do?

here's simple code:

.graph {  width:200px; margin-left:25px; height:20px;  background: rgb(168,168,168);  background: -moz-linear-gradient(top, rgba(168,168,168,1) 0%, rgba(204,204,204,1) 23%);  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(168,168,168,1)), color-stop(23%,rgba(204,204,204,1)));  background: -webkit-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  background: -o-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  background: -ms-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#a8a8a8', endcolorstr='#cccccc',gradienttype=0 );  background: linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  position: relative;    }  #bar {  background:#09c; height:20px;                 }
<div id="progress" class="graph"><div id="bar" style="width:50%;"></div></div>  <br>  <form>  <input type="range" min="0" max="100"  step="5" onchange="rangevalue.value=value" id="textvalue" />  <br>  <input type="text" maxlength="3" id="rangevalue" onchange="textvalue.value=value">  </form>

simple, hook change event slider & textbox, , adjust bar appropriately.

$(document).on('change','#rangevalue, #textvalue',function(){    $('#bar').css('width',$(this).val() + '%');    });
.graph {  width:200px; margin-left:25px; height:20px;  background: rgb(168,168,168);  background: -moz-linear-gradient(top, rgba(168,168,168,1) 0%, rgba(204,204,204,1) 23%);  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(168,168,168,1)), color-stop(23%,rgba(204,204,204,1)));  background: -webkit-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  background: -o-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  background: -ms-linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  filter: progid:dximagetransform.microsoft.gradient( startcolorstr='#a8a8a8', endcolorstr='#cccccc',gradienttype=0 );  background: linear-gradient(top, rgba(168,168,168,1) 0%,rgba(204,204,204,1) 23%);  position: relative;    }  #bar {  background:#09c; height:20px;                 }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <div id="progress" class="graph"><div id="bar" style="width:50%;"></div></div>  <br>  <form>  <input type="range" min="0" max="100"  step="5" onchange="rangevalue.value=value" id="textvalue" />  <br>  <input type="text" maxlength="3" id="rangevalue" onchange="textvalue.value=value">  </form>


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -