Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery Range Input Listener

Hey having a little trouble jquery and the hmtl5 range. I'm try to get the values as they changed but the event listener is not capturing it. Currently my code is:

HTML

html += '<li>Apply Credits: <input type="range"  min="0" max="'+credits+'" name="discount_credits" id="discount_credits" /> <span>'+credits+'</span></li>' 

And the JS is:

$('#discount_credits').mousewheel( function() {          alert('it changed!');          alert('new value = ' + $(this).val());      }); 

I've also tried

$('#discount_credits').change( function() {              alert('it changed!');              alert('new value = ' + $(this).val());          }); 

Neither seem to work. Am I doing something wrong?

like image 637
Devin Dixon Avatar asked May 06 '12 19:05

Devin Dixon


Video Answer


1 Answers

$('input[type=range]').on('input', function () {     $(this).trigger('change'); }); 

This fires the change event on every input event.

like image 185
Brian Avatar answered Sep 20 '22 00:09

Brian