jquery - How to simulate anchor link click -
i'm trying trigger link click .jquery. know why following doesn't work.
<!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html lang="en"> <head> <title>test</title> </head> <body> <div> <a id="google_link" href="http://google.com" target="_blank">click go google</a> </div> <div id="google_link_proxy">click here same link above</div> <script type="text/javascript"> $("#google_link_proxy").click(function(event){ $("#google_link").click(); }); </script> </body> </html>
looks $("google_link_proxy") selector off. try $("#google_link_proxy").
you need close observe call }).
those syntax errors code above though don't think functions provided in jquery default.
here think you're after:
$("#google_link_proxy").click(function(event){ window.open($("#google_link").attr('href'),'_blank') });
Comments
Post a Comment