Basically I need to call .range::-webkit-slider-runnable-track
using either jquery or javascript so I can make some changes over to it's background and do other implementations over it.
To be precise I am currently using
$('<style>.myrange::-webkit-slider-runnable-track{background:linear-gradient(to right, white'+val+'%, #bbb '+val+'%);}</style>').appendTo('head');
This works pretty much fine, but the problem is that I'm calling .myrange::-webkit-slider-runnable-track
like couple of thousands of times which every time it appends to head my range gets to face some performance issue and so.
I would really appreciate if some one tell how to do this with something like $('.myrange::-webkit-slider-runnable-track').css("background", "black");
Question Update:
<input type="range" value="0" min="0" max="100" id="myrange" class="myrange"/>
This range
has connected to a video which track the video duration and changes the color of the track up to the point that the video has been watched.
And to do the coloring of the range tracker this is what I am doing:
vid.addEventListener('progress', function() {
var range = 0;
var bf = this.buffered;
var time = this.currentTime;
while(!(bf.start(range) <= time && time <= bf.end(range))) {
range += 1;
}
var loadStartPercentage = bf.start(range) / this.duration;
var loadEndPercentage = bf.end(range) / this.duration;
var loadPercentage = loadEndPercentage - loadStartPercentage;
val = loadPercentage*100;
thmpos = $('.vidskb_r').val();
var style = $("<style>", {type:"text/css"}).appendTo("head");
style.text('.vidskb_r::-webkit-slider-runnable-track{background:linear-gradient(to right, #ff7e20 '+thmpos+'%, #fff '+thmpos+'%, #fff '+val+'%, #bbb '+val+'%);}');
});
Thanks in advance:)