1

I'm trying to dynamically change a page when the the input range is changed to different values? Anyway for jquery to check the value on the fly and allow me to set conditions when the range is moved to a certain value? Thanks

<input type="range" min="0" max="100" name="adjust" id="range"/>

if ( $('input[type="range"]').is().val(50) ) {

 alert('Value is 50');

}
2
  • You should check out answers to this question: stackoverflow.com/questions/10473554/… Commented Nov 14, 2016 at 0:13
  • 1
    This is exactly why you should never learn jQuery before JS. Commented Nov 14, 2016 at 0:25

1 Answer 1

2

Attach OnChange event handler:

  $(function(){
      $("#range").change(function(){        
        if ( $(this).val() == "50")
        {
            alert('Value is 50');
        }
        $("#value").text($(this).val());
      });    
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

<input type="range" min="0" value="25" max="100" name="adjust" id="range"/>

<span id="value"></span>

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.