I am in the process of converting jquery to javascript and on one page we have some range sliders we set all the ticks in jquery and I’m wondering how to do this…
jquery:
$("#months").slider({
ticks:[12, 24, 36],
ticks_labels: [‘12’,‘24’,‘36’],
step:12,
ticks_snap_bounds:12,
ticks_positions:[0, 50 ,100],});
$("#users").slider({
ticks: [25, 100, 500, 1000],
ticks_labels: [‘25’, ‘100’, ‘500’, ‘1000+’],
ticks_snap_bounds: 1,
step: 1,
ticks_positions: [0,30,65,100], });
I did try this but it did not work:
var monthslider = document.getElementById(‘months’);
var usersslider = document.getElementById(‘users’);
var monthsTicks = {
ticks:[12, 24, 36],
ticks_labels: [‘12’,‘24’,‘36’],
step:12,
ticks_snap_bounds:12,
ticks_positions:[0, 50 ,100],
};
var usersTicks = {
ticks: [25, 100, 500, 1000],
ticks_labels: [‘25’, ‘100’, ‘500’, ‘1000+’],
ticks_snap_bounds: 1,
step: 1,
ticks_positions: [0,30,65,100],
};
Object.assign(monthslider.style, monthsTicks);
Object.assign(usersslider.style, usersTicks);