将滑块值传递给其他功能 [英] Passing Slider Value to Other Functions

查看:82
本文介绍了将滑块值传递给其他功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我发布了一个类似的问题,并做了更多的研究和编码,现在我正处于困境.我是一个新手,需要更多帮助.

I posted a similar question a few days ago and have done a bit more research and coding, and now I'm at a wall. I'm a complete newbie and needing more help.

我目前在同一页面上成功绘制了一个滑块和两个图表.我想将滑块的值传递到两个图表函数中,以便随着滑块的移动,图表刷新.滑块是使用jQuery UI函数生成的.图表由Highcharts函数生成.

I currently have one slider and two charts successfully rendering on the same page. I'd like to pass the value of the slider into the two chart functions such that as the slider is moved, the charts refresh. The slider is generated using the jQuery UI function. The charts are generated by the Highcharts function.

jQuery Slider API中有一个名为"value()"的方法",它将检索滑块的值,如下所示:

There is a "Method" in the jQuery Slider API called "value()" that will retrieve the value of the slider, as follows:

var selection = $( ".selector" ).slider( "value" );

当前,图表的值被硬编码为图表功能代码中的数字.我想根据滑块的值动态更新图表的值.

Currently, the values for the charts are hard coded as numbers within the function code for the charts. I'd like to dynamically update the values for the charts based on the value of the slider.

想法?

谢谢

克里斯

推荐答案

您可以在jquery用户界面文档中使用change函数

you could use the change function in the jquery UI documentation

$(function() {

    $("#slider").slider({
     change: function (event,ui){
      // your code here
    }
});
});

这应该在每次滑块更改时都有效

this should work for every time there is a change in your slider

这就是您的代码的外观

 change: function(event,ui)
      {
        $( "selector" ).val( ui.value );
      }

这篇关于将滑块值传递给其他功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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