There's not really that many ways. John's method is (AFAIK) the only way that actually works. i.e.:
$('div.test').click(function(event){ location.href = $('a').attr('href') }); It's not actually jQuery problem, just the way browsers do it. Even if you called ".click()" on a raw link it would not do the same thing as the user clicking on the link. No idea why it's that way. Karl Rudd On 8/22/07, Mitchell Waite <[EMAIL PROTECTED]> wrote: > > > > > Does anyone know why there are so many ways to do this? > > > > > From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of John Beppu > Sent: Tuesday, August 21, 2007 8:56 PM > To: jquery-en@googlegroups.com > Subject: [jQuery] Re: divert click to an anchor > > > > > $('div.test').click(function(event){ location.href = $('a').attr('href') }); > > > > On 8/21/07, John Liu < [EMAIL PROTECTED]> wrote: > > > <html><head> > <script language=javascript src=" jquery-1.1.3.1.js"></script> > <script language=javascript> > $(document).ready(function(){ > $("div.test").click(function(){ > alert('div.test clicked'); > $("a").click(); > }); > }); > </script></head><body> > <a href="http://google.com"> google </a> > <div class='test'>click</div> > </body></html> > > I have a situation where if anyone clicks anywhere within the div, I > want the anchor to be fired - in this case, navigate to google.com. > Why doesn't the above code work? > > thanks in advance. > jliu > >