问题
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.
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.
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.
Ideas?
Thanks,
Chris
回答1:
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
this is how your code should look like
change: function(event,ui)
{
$( "selector" ).val( ui.value );
}
来源:https://stackoverflow.com/questions/13781489/passing-slider-value-to-other-functions