【发布时间】:2020-02-24 16:39:09
【问题描述】:
我有一个包含多个范围滑块的页面。我想根据值控制输出。是否可以使此功能适用于同一页面上的多个滑块?还是我必须为每个输入使用新的 ID 重新编写函数?
代码:
$(".slider").mousemove(function () {
if ($(this).val()==this.min) {
$(".priceOutputId").text("Less than $80")
}
else if ($(this).val()==this.max) {
$(".priceOutputId").text("More than $100")
}
else {
$(".priceOutputId").text("around $" + $(this).val())
}
}
)
<label class="radio_title">
<input type="range" min="80" max="100" value="80" class="slider" id="priceInputId">
<div class="range_output">
<output name="priceOutputName" class="priceOutputId">Less Than $80</output>
</div>
</label>
<label class="radio_title">
<input type="range" min="80" max="100" value="80" class="slider" id="priceInputId">
<div class="range_output">
<output name="priceOutputName" class="priceOutputId">Less Than $80</output>
</div>
</label>
【问题讨论】:
-
是的,可以使用单个函数,但是您遇到了什么问题?你卡在哪里了?
标签: jquery rangeslider