Here is the code for the slider with a range of 1 to 5, value showing, single selector starting from zero, and transition effect:

HTML:

<div id="slider"></div>
<p>Value: <span id="slider-value"></span></p>

CSS:

#slider {
  width: 200px;
  margin: 20px;
}

.ui-slider-handle {
  background-color: #007bff;
  border-color: #007bff;
  transition: all .2s ease-in-out;
}

.ui-slider-range {
  background-color: #007bff;
}

JavaScript:

$(function() {
  $("#slider").slider({
    range: "min",
    value: 0,
    min: 0,
    max: 5,
    slide: function(event, ui) {
      $("#slider-value").html(ui.value);
      switch(ui.value) {
        case 1:
          $("#slider").css("background-color", "#ff8080");
          break;
        case 2:
          $("#slider").css("background-color", "#ffc266");
          break;
        case 3:
          $("#slider").css("background-color", "#ffff66");
          break;
        case 4:
          $("#slider").css("background-color", "#99ff66");
          break;
        case 5:
          $("#slider").css("background-color", "#66ff66");
          break;
        default:
          $("#slider").css("background-color", "#f2f2f2");
      }
    }
  });
  
  $("#slider-value").html($("#slider").slider("value"));
});

In the CSS, I added a transition effect to the slider handle and a background color to the range. In the JavaScript, I added a switch statement to change the background color of the slider container based on the value selected. The selected value is also displayed in a span element with the ID "slider-value".

i want jquery ui slide with range 1 to 5 with value showingonly single selector start from zero also i want to addi want selector move with a transitionalso i want to change background container for

原文地址: https://www.cveoy.top/t/topic/bNni 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录