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?
Does not seem to have any problem on HTML5
<input type="range">
usingchange
.See: http://jsfiddle.net/DerekL/BaEar/33/
This fires the
change
event on everyinput
event.The on change event seems to be working correctly for me: http://jsfiddle.net/zV3xD/7/
Or you can try something like this:
Using the
output
example here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/outputI assume your span has an id:
<span id="slidernumber">...</span>
Lets also assume that you have a few sliders, and you want to see a text change if any of them were moved:Try this:
http://jsfiddle.net/MahshidZeinaly/CgQ5c/
Now lets assume that you have a few sliders, but you want to see a text change if a particular one of them were moved. (I assume it because the range input is inside li tag, and you gave it a name):
Try this:
http://jsfiddle.net/MahshidZeinaly/2pe7P/1/
Several test and bug fixed!