如何从jQuery范围滑块获取值

时间:2018-07-26 14:18:20

标签: javascript jquery html

我正在使用ui jquery滑块,但无法获取该值。

$("#ex1").slider({
  value: 1400,
  min: 1400,
  max: 12000,
  step: 20,
  slide: function(event, ui) {
    $("#slider-value").html(ui.value);
  }
});
$("#slider-value").html($('#ex1').slider('value'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" />
<input id="ex1" data-slider-id='ex1Slider' type="range" data-slider-min="1400" data-slider-max="12000" data-slider-step="20" data-slider-value="0" /><b class="price-left">
<span id="slider-value"></span>

有人可以帮我吗?

2 个答案:

答案 0 :(得分:1)

您的问题是因为您要在$ docker build -t wptest . --no-cache Sending build context to Docker daemon 2.048kB Step 1/5 : FROM wordpress:apache as codebase ---> 1d3cc82944da Step 2/5 : FROM wordpress:cli as cli ---> ee57985dea6f Step 3/5 : COPY --from=codebase /usr/src/wordpress /var/www/html ---> e10d62f3d7bc Removing intermediate container e09a35e05108 Step 4/5 : RUN wp --path=/var/www/html config create --dbname=dbname --dbuser=dbuser --skip-check && ls /var/www/html/wp-config.php ---> Running in 8b2b3e98163e Success: Generated 'wp-config.php' file. /var/www/html/wp-config.php ---> b0934cfed497 Removing intermediate container 8b2b3e98163e Step 5/5 : RUN ls /var/www/html/wp-config.php ---> Running in cda6a5c16fb5 ls: /var/www/html/wp-config.php: No such file or directory The command '/bin/sh -c ls /var/www/html/wp-config.php' returned a non-zero code: 1 元素上实例化slider()。应该与普通的input type="range"一起使用。更改它,其余代码可以正常工作:

div
$("#ex1").slider({
  value: 1400,
  min: 1400,
  max: 12000,
  step: 20,
  slide: function(event, ui) {
    $("#slider-value").html(ui.value);
  }
});
$("#slider-value").html($('#ex1').slider('value'));

滑块documentation全面说明了您可以使用的所有其他方法和属性。

答案 1 :(得分:-1)

 $('#ex1').slider("option", "value");

您可以尝试这个(y)