请帮助我如何在滑块边框的末端停止滑块手柄停止。
DEMO:
body{
padding:50px
}
#slider{
height:50px;
border-radius:50px;
border-color:#1C2128;
}
#slider span {
height: 50px;
border-radius: 50px;
top: 0;
width: 80px;
margin-left: 0;
border:0;
background:#69B253;
}

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#slider" ).slider();
});
</script>
</head>
<body>
<div id="slider"></div>
</body>
</html>
&#13;
我尝试了很多解决方案但是没有用。
如何直接在该滑块上添加样式以停止右边框处理?我需要通用功能。请帮帮我。
答案 0 :(得分:0)
也许这不是完美的解决方案
我使用change
事件来检测滑块
body{padding:50px}
#slider{height:50px;border-radius:50px;border-color:#1C2128;}
#slider span {
height: 50px;
border-radius: 50px;
top: 0;
width: 80px;
margin-left: 0;
border:0;
background:#69B253;
}
#slider {
overflow: hidden;
}
#slider.finished span {
margin-left: -80px;
}
&#13;
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Slider - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#slider" ).slider({
change: function(event, ui) {
console.log(ui.value);
if (ui.value >= 80) {
$( "#slider" ).addClass('finished')
} else {
$("#slider").removeClass('finished')
}
}
});
} );
</script>
</head>
<body>
<div id="slider"></div>
</body>
</html>
&#13;