Skip to content

Instantly share code, notes, and snippets.

@aimahdi
Created October 5, 2021 10:21
Show Gist options
  • Save aimahdi/7a4daa55e56d6fc3078ccc5e2045a053 to your computer and use it in GitHub Desktop.
Save aimahdi/7a4daa55e56d6fc3078ccc5e2045a053 to your computer and use it in GitHub Desktop.
range slider: put comma and a dollar sign before the number
let rangeSlider = document.querySelector("#ff_258_rangeslider");
let rangeValue = document.querySelector(".ff_range_value");
rangeSlider.onchange = function(event){
let commaValue = event.target.value.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
rangeValue.innerText = "$ "+commaValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment