[英]How to make a range slider with spefic bar color
使用jQuery:
HTML:
<div id="slider"></div>
CSS:
#slider
{
background-color:red;
background-position:left;
background-repeat:no-repeat;
background-size:10px;
}
Javascript:
$(function() {
$( "#slider" ).slider(
{
slide:function(event, ui){
//This is what the original code for this example looks like.
//It's for changing the white/red area when the slider moves.
//var w = $(ui.handle).css("left");
//$(this).css("background-size",w);
//Notice how when you set the "w" value to a static value it
//will keep the white/red space static as well? So you can
//change the colored space with whatever logic you want to use.
$(this).css("background-size",50);
}
});
});
做任何涉及更改背景的寬度和顏色的操作。 您所舉的示例網站似乎是根據對租購之間的門檻值以及一個人對另一個人變得理想時所進行的計算得出的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.