如何更改 Jquery UI 滑块句柄 [英] How to change Jquery UI Slider handle

查看:19
本文介绍了如何更改 Jquery UI 滑块句柄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想修改普通的 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:

但我无法让它工作.以下代码生成静止的句柄图像:

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>

好像 JQuery 没有接收到我想使用 myhandle id 作为句柄.我想知道:我需要一个 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-horizo​​ntal .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".

以下代码演示:

<!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 滑块句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆