Every jQuery UI plugin option can be get or set after initialization. So you
can get the current value of the slider:
var val = $("#slider").slider("option", "value");
and you can set it to a new value:
$("#slider").slider("option", "value", 7);
In addition to the value option, slider also has a value method, which is
nearly identical in function, but simpler to call:
var val = $("#slider").slider("value"); // getter
$("#slider").slider("value", 7); // setter
Docs:
http://docs.jquery.com/UI/Slider#option-value
http://docs.jquery.com/UI/Slider#method-value
- Richard
On Wed, Apr 1, 2009 at 6:54 AM, kallep <[email protected]> wrote:
>
> Thanks Richard. I actually found this solution earlier on but due to
> my problems to understand what the code does. I was not able to get it
> to work. What are the "option value" do?
>
> $(function() {
> $("#slider").slider({
> range: "min",
> min: 1,
> max: 10,
> value: 1,
> slide: function(event, ui) {
> //next button
> // $("li.next").click(function(){
> // $("#slider").slider( 'value' , ((ui.value)
> + 1) )
> // });
>
> $("li.next").click(function(){
> var s = $("#slider"), val =
> s.slider("value"), step = s.slider
> ("option",
> "1");
> s.slider("value", val - step);
> });
> });
> </script>
> </head>
> <body>
> <ul id="nav">
> <li class="next"><a href="#">next</a></li>
> </ul>
> <div id="slider"></div>
> </body>
>
>
>
>
>
> On Mar 31, 11:37 pm, "Richard D. Worth" <[email protected]> wrote:
> > See this thread for two options:
> >
> > Slider next - previous buttonshttp://
> groups.google.com/group/jquery-ui/browse_thread/thread/985be41...
> >
> > - Richard
> >
> > On Tue, Mar 31, 2009 at 6:43 AM, kallep <[email protected]> wrote:
> >
> > > Hello everybody on this list. This is my first post here. I am new to
> > > Jquery and have during the last days been trying to get an
> > > understanding for how everything works, but it is still some concepts
> > > I do not get.
> >
> > > In the code below I have successfully been able to add next and
> > > previous buttons to the Jquery UI slider. The problem is that I'm not
> > > able to get the new values back.
> >
> > > In other words I can click the Next button ones and it works but
> > > nothing happens if I click a second time.
> >
> > > $(function() {
> > > $("#slider").slider({
> > > range: "min",
> > > min: 1,
> > > max: 10,
> > > value: 1,
> > > slide: function(event, ui) {
> >
> > > //next button
> > > $("li.next").click(function(){
> > > $("#slider").slider( 'value' , [((ui.value) +
> 1)]
> > > )
> > > });
> > > //previous button
> > > $("li.previous").click(function(){
> > > $("#slider").slider( 'value' ,
> [((ui.value)
> > > - 1)] )
> > > });
> >
> > > }
> > > });
> > > });
> > > </script>
> > > </head>
> > > <body>
> > > <ul id="nav">
> > > <li class="next"><a href="#">next</a></li>
> > > <li class="previous"><a href="#">previous</a></li>
> > > </ul>
> >
> > > <div id="slider"></div>
> > > </body>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"jQuery UI" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jquery-ui?hl=en
-~----------~----~----~----~------~----~------~--~---