2
$(function() {
    setInterval( "clickRight()", 5000 );
});

    $('.slide_right').click(function clickRight(){ 
etc...

I basically want my slideshow to move to the next slide as if the user clicked the right button. This example is not working for me.

Adam
  • 8,599
  • 16
  • 66
  • 128
  • 2
    Please **do not** pass strings to `setInterval` and `setTimeout`. It's `eval` in disguise, and every time you use `eval`, a ninja chops off a kitten's head. ☹ – Matt Ball Jan 27 '11 at 16:47

6 Answers6

8
$('.slide_right').trigger('click');

or

$('.slide_right').click();
Jamiec
  • 128,537
  • 12
  • 134
  • 188
4

You can trigger an event

$("element").trigger("event");

Bind the event to an element:

$("element").bind("event");

It does accept normal events like click, ... and also custom events.

BrunoLM
  • 94,090
  • 80
  • 289
  • 441
4
setInterval( "clickRight()", 5000 );

function clickRight()
{
   $('.slide_right').trigger('click'); 
};
Mark Schultheiss
  • 30,473
  • 11
  • 66
  • 95
0

You can use trigger to force your event:

function clickRight(){
 $('.slide_right').trigger('click');
}

$(function() {
    setInterval( "clickRight()", 5000 );
});
wajiw
  • 12,055
  • 17
  • 52
  • 73
0

You can give a name to the click function and do a setInterval like this...

$("#Id").click(function _clickFunction(){
  something();
};  

interval=setInterval( function{
  _clickFunction();
},5000);
Thiago
  • 1,487
  • 3
  • 25
  • 40
0
document.getElementById("id").click()
// "id" is the element which you want to trigger click() action
Tomerikoo
  • 15,737
  • 15
  • 35
  • 52
Bahubali Ak
  • 143
  • 1
  • 8