-3

jQuery:

$(document).on('mouseover', '.image_slider', function() {
    setInterval(slider(this), 10000);
});
function slider(that){
  console.log(that);
}

Anyone can please tell me Why this function is not working and How can I resolve it?

yuriy636
  • 10,074
  • 5
  • 38
  • 42

1 Answers1

0

window.setInterval executes the parameter after the given time. Therefore you should execute it as such:

setInterval ( myFunction, 1000 );

Or

$(document).on('mouseover', '.image_slider', function() {
    setInterval(function (e){
        slider (this)
    }.bind (this), 10000);
});
function slider(that){
  console.log(that);
}
Hassan Imam
  • 20,493
  • 5
  • 36
  • 47
BRO_THOM
  • 806
  • 9
  • 23