gpt4 book ai didi

jquery - 如何更改 Jquery UI slider handle

转载 作者:行者123 更新时间:2023-12-03 21:28:14 25 4
gpt4 key购买 nike

我想修改普通的 JQuery UI slider ,以便 handle 上有一个箭头而不是一个正方形。即我想使用自定义图像作为句柄。

有一些教程可以做到这一点:

但我无法让它工作。以下代码会生成固定 handle 图像:

<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.slider.js"></script>
<style type="text/css">
#myhandle {position: absolute;z-index: 100;height: 25px;width: 35px;top: auto;background: url(http://stackoverflow.com/content/img/so/vote-arrow-down.png) no-repeat;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#slider").slider({handle: '#myhandle'});
});
</script>
</head>
<body>
<div id="slider"><div id="myhandle"></div></div>
</body>
</html>

就好像 JQuery 没有识别出我想使用myhandle id 作为句柄。我想知道:我是否需要 JQuery 插件来识别 handle 选项? (它没有记录在 http://docs.jquery.com/UI/Slider 中)。或者也许它只适用于旧版本的 JQuery?

有什么想法吗?

最佳答案

可以更改以将图像添加到 JQuery slider 句柄的 CSS 类称为“.ui-slider-horizo​​ntal .ui-slider-handle”。

以下代码显示了一个演示:

<!DOCTYPE html>
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.slider.js"></script>
<style type="text/css">
.ui-slider-horizontal .ui-state-default {background: white url(http://stackoverflow.com/content/img/so/vote-arrow-down.png) no-repeat scroll 50% 50%;}
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#slider").slider();
});
</script>
</head>
<body>
<div id="slider"></div>
</body>
</html>

我认为注册 handle 选项是旧的做法,JQuery-ui 1.7.2 不再支持?

关于jquery - 如何更改 Jquery UI slider handle ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1207307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com