I have a href link and I would like it to be clicked when the page is loaded.
+9
A:
$().ready(function() {
$('#someLinkId').click();
});
Or
$().ready(function() {
$('#someLinkId').trigger("click");
});
karim79
2009-07-08 13:19:40
A:
What's the point of loading the page if you're going to navigate away from it immediately?
In addition to jQuery's triggering abilities, you could do:
<body onload="window.location.replace('http://example.com/');">
or:
<body onload="window.location.href = 'http://example.com/';">
ceejayoz
2009-07-08 13:20:19
+1
A:
$("#whateverid").trigger("click");
Where "whateverid" is the ID of the anchor tag, or whatever other selector you want to use.
mgroves
2009-07-08 13:20:41
+1
A:
$(document).ready(function () {
$("#myLink").trigger('click');
});
as you can read in: http://docs.jquery.com/Events/trigger#eventdata
kajyr
2009-07-08 13:20:48