I am javascript/jquery noobie. Trying to hack together something for personal project How to access elements using jquery from within setTimeout. I am trying to click a button after three seconds and I tried the following Eg
setTimeout((){$("#id1").click()}, 3000)
However I am not able to access any element from within the setTimeout. I have to hold reference to the element outside and then click.
var ele = $("#id1");
setTimeout((){ele.click()}, 3000)
How can I acces elements from within a setTimeout
or setInterval
EDIT: I do not have access to all the div elemets and cannot store in a variable or attach it to a timeout I have to click a button after 3 seconds. Another button will be available after I click this. The second button is not hidden but simple not available. So I need something like this
$("#id1").click();
setTimeout((){
$("#id2").click();
}, 3000);
}, 3000)