Is there any way to get the pixel position of the slider handle of an HTML5 range input ?
<input type="range" id="combicalc_contribution-slider" min="1" max="50" value="25">
I have tried calculating the position using a combination of max, min & value to work out the percentage 'down the track' but the calcualted value varies to the left at lower values and the right at higher values.
Here's the code for that:
var sliderWidth = slider[0]['clientWidth'];
var sliderPos = slider[0]['valueAsNumber'] / slider[0]['max'];
jQuery(id).closest('.sliderContainer').append('<div class="sTt">' + val + '</div>');
var sTtWidth = jQuery(id).closest('.sliderContainer').find('.sTt').outerWidth(true) / 2;
var ttPos = (sliderWidth * sliderPos);
ttPos = ttPos - sTtWidth;
ttPos = ttPos + 'px';
jQuery('.sTt').css({'left': ttPos});
The overall aim is to place a 'tooltip' above the slider handle as it moves with the value in it.
Here's a jsFiddle which highlights the issue

