Created
February 1, 2019 03:42
-
-
Save keyserfaty/61e72badbc2d3c9978f0c3a472095d4c to your computer and use it in GitHub Desktop.
slider js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var max = 500000; | |
$(document).ready(function(){ | |
var slider = $('.slider'); | |
var output = $('.output'); | |
var sliderRight = $('.slider-right'); | |
function getPercentage (val) { | |
return val * 50 / max; | |
} | |
function getSliderRightWidth (val) { | |
return 100 - getPercentage(val) + '%'; | |
} | |
function GetValueFromRange(sli, out){ | |
sli.on('input', function(){ | |
console.log(getPercentage(sli.val())) | |
value = sli.val() | |
out.text(value + '$'); | |
sliderRight.css('width', getSliderRightWidth(value)); | |
}) | |
} | |
var value = slider.val() | |
output.html(value + '$'); | |
GetValueFromRange(slider, output); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment