I have a slider class like this and I wan to change the style attribute style="left: 336px"
<div id="range-cont"> <div class="slider"> <div class="progress" style="width: 350px;"></div> <a class="handle" href="#" **style="left: 336px;"**></a> </div> <input id="percentage" class="range" type="range" value="14" name="percentage" min="0" max="100"> <p id="percent-label">%</p> </div> </div>
I tried $('.handle').css({'style':'left: 300px'})
but its not working. Not sure what I am doing wrong here
Just try $('.handle').css('left', '300px');
if you just want to set the style attribute use
$('.handle').attr('style','left: 300px');
Or you can use css method of jQuery to set only one css style property
$('.handle').css('left', '300px');
OR same as key value
$('.handle').css({'left': '300px', position});
More info on W3schools
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With