如何更改Jquery UI Slider句柄 [英] How to change Jquery UI Slider handle
问题描述
我想修改库存JQuery UI滑块,以便手柄上带有箭头而不是正方形.即我想使用自定义图片作为句柄.
I want to modify the stock JQuery UI slider so that the handle has a arrow on it rather than being a square. i.e. I want to use a custom image as the handle.
有一些教程可以做到这一点:
There are a few tutorials that do it:
- http://jqueryfordesigners.com/slider-gallery/
- http://www.ryancoughlin.com /2008/11/04/using-the-jquery-ui-slider/
- http://www.keepthewebweird.com/creating -a-nice-slider-with-jquery-ui/
- http://jqueryfordesigners.com/slider-gallery/
- http://www.ryancoughlin.com/2008/11/04/using-the-jquery-ui-slider/
- http://www.keepthewebweird.com/creating-a-nice-slider-with-jquery-ui/
但是我无法使它正常工作.以下代码生成固定的手柄图像:
But I can't get it to work. The following code results in a stationary handle image:
<!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>
我想使用 myhandle id作为句柄,好像JQuery没接.我想知道:我是否需要JQuery插件才能识别 handle 选项? (未在 http://docs.jquery.com/UI/Slider 中进行记录).还是只能在旧版本的JQuery中使用?
It is as if JQuery doesn't pick up that I want to use the myhandle id for the handle. I'm wondering: Do I need a plugin for JQuery to recognise the handle option? (it is not documented in http://docs.jquery.com/UI/Slider). Or perhaps it only worked in an old version of JQuery?
有什么想法吗?
推荐答案
可以更改以将图像添加到JQuery滑块句柄的CSS类称为" .ui-slider-horizontal .ui-slider-处理".
The CSS class that can be changed to add a image to the JQuery slider handle is called ".ui-slider-horizontal .ui-slider-handle".
以下代码显示了一个演示:
The following code shows a demo:
<!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中不再受支持吗?
I think registering a handle option was the old way of doing it and no longer supported in JQuery-ui 1.7.2?
这篇关于如何更改Jquery UI Slider句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!