First off, I'm not sure this is even possible, but I thought I'd
ask...

Is it possible to use jQuery (or just plain JavaScript) to simulate a
link click?

Can something like this be done?

// Script

function doSomething()
{
   // executes some code
}

$(document).ready(function()
{
   $("#MyLink").... // Some code that causes Link 1 to execute as if
it was clicked when Link 2 is clicked
}

// Markup

<a href="#" onclick="doSomething" />Link 1</a>     // Link 1

<a href="#" id="MyLink" />Link 2</a>                     // Link 2

Also, I don't want Link 2 to call the function directly; I want it to
cause Link 1 to be "clicked."

I've been trying to figure this out for a long time, and I'm pretty
stumped.

Reply via email to