[英]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.