-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
  • 11,171
  • 5
  • 37
  • 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
  • 21,956
  • 5
  • 41
  • 51
BRO_THOM
  • 824
  • 9
  • 24