Reputation: 11
Heres my current attempt:
<div class="links">
<a href="/login">Login</a>
<a href="/register">Register</a>
</div>
My JQuery For This Attempt Is:
setTimeout (
function()
{
alert("Clicking Now");
$('.links a:contains("Register")').trigger('click');
}, 2000);
This doesn't seem to click the href link after 2 seconds... Any help please?
Upvotes: 0
Views: 26
Reputation: 2745
jQuery has a built in function $(el).click()
try using that first.
Certain browsers limit your ability to do actions that would typically have to be taken by the user (click, copy, paste), but you can still trigger/broadcast the events so that anything triggered by an eventListener can pick it up.
For this particular goal, I think it would be more appropriate to redirect the user to your login page, using something like window.location.href = '/login'
Upvotes: 1