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,849
  • 16
  • 67
  • 131
  • 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
  • 133,658
  • 13
  • 134
  • 193
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
  • 97,872
  • 84
  • 296
  • 452
4
setInterval( "clickRight()", 5000 );

function clickRight()
{
   $('.slide_right').trigger('click'); 
};
Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100
0

You can use trigger to force your event:

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

$(function() {
    setInterval( "clickRight()", 5000 );
});
wajiw
  • 12,239
  • 17
  • 54
  • 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,547
  • 3
  • 25
  • 40
0
document.getElementById("id").click()
// "id" is the element which you want to trigger click() action
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Bahubali Ak
  • 181
  • 3
  • 13