A
A
Anton Misyagin2015-11-01 02:43:06
JavaScript
Anton Misyagin, 2015-11-01 02:43:06

How to make range slider state update instantly?

Essentially you need no additional plugins. The code I provide is working. What is missing is that the value in the field is updated as the slider is dragged, and not after it is released. How?8647f22dca9a4deeb3c67d1291930f39.png

//Диапазон значений:
$(function(){
  $("input[type=range]").each(function(){
    $(this).wrap('<div class="range-wrapper"></div>');
    var min = $(this).attr("min");
    var max = $(this).attr("max");
    var step = $(this).attr("step");

    var input = $('<input class="narrow-input" type="number" min="'+min+
      '" max="'+max+
      '" step="'+step+'">');
    $(this).after(input);
    $(input).val($(this).val())
    $(this).change(function(){
      $(input).val($(this).val());
    })

    $(input).change(function(){
      $(input).prev().val($(input).val());
    })
  });
});
//============================================================

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question