开发者

how to get the value selected in this jquery slider [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

here is the code

<script> 
  $( ".slider" ).slider({
    animate: true,
    range: "min",
    value: 0,
 开发者_运维百科   min: 0,
    max: 4,
    step: 1,

  //this gets a live reading of the value and prints it on the page
  slide: function( event, ui ) {
    if(ui.value ==0)
      $( "#slider-result" ).html( "Poor");
    else if(ui.value == 1)
      $( "#slider-result" ).html( "Average");
    else if(ui.value == 2)
      $( "#slider-result" ).html( "Good");
    else if(ui.value == 3)
      $( "#slider-result" ).html( " Very Good");
    else if(ui.value == 4)
      $( "#slider-result" ).html( "Excellent");                     
    },

  //this updates the hidden form field so we can submit the data using a form
  change: function(event, ui) { 
    $('#hidden').attr('value', ui.value);
    }
  });
</script>

this slider create a jquery slider and display "excellent verygood good poor" and so on. on selecting . now i need to get the value of slider selected how to do that????


Your code is setting the value of an element with id "hidden" when the slider changes. See the line:

$('#hidden').attr('value', ui.value);

You should therefore be able to get the current value of the slider by getting the value of that element:

var currentValue = $('#hidden').val();

However, the hidden input with id "hidden" does not have an initial value, so this won't work if the slider has not yet changed. You can fix that by giving a value to that hidden input element.

I am assuming the entire reason you have it updating a hidden input element on change is so you can access that value at some point...


slider value is stored in the... value: $(".slider").slider.value

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜