Search code examples
jqueryjquery-uijquery-ui-slider

value not available in create event on jQuery UI slider?


$('#foo').slider({
  range: 'min',
  min: 0,
  max: 1000,
  step: 100,
  value: 500,
  create: function( event, ui) {
          var bar = ui.value;
  },
  //etc...
});

Why is bar undefined and not 500? Is it possible to assign a variable to the value in the create event?


Solution

  • You can also use

    create: function( e, ui ) {
        var bar=$(this).slider('value');
    }
    

    DEMO.