I am creating a jQuery slider to loop through a collection of divs, if I hold the slider down and drag it and let go. The handleSlider() is called. If I click on a random point in the slider, the function never gets called. I’ve tried to use two other event types with no luck. Is there an event handler for "When the user clicks/jumps" on the slider without sliding?
$( "#video_seek" ).slider({
range: "max",
step: 1,
slide: function( event, ui ) {
handleSlider();
}
});
$( "#video_seek" ).slider({ stop: function( event, ui ) {handleSlider();}});
$( "#video_seek" ).slider({ change: function( event, ui ) {handleSlider();}});
I believe your problem is in the syntax. Every time you use $ it makes a new jQuery object, so
@Andrew is correct in his syntax. All you should need is the ‘change’ event, which you can set in your original declaration like this:
or even like this:
if you need to attach an event handler after the fact, do so like this:
or even:
(Edit)
Putting it all together and avoiding the production of subsequent jQuery objects.