Try:
function linkClick() {
var target = $('body').find('#test').attr('href');
window.location = target;
}
Maurício
-----Mensagem Original-----
De: "Andy789" <e...@abcstudio.com.au>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: sábado, 31 de janeiro de 2009 05:15
Assunto: [jQuery] Triggering a link with no click event
HI All,
It could be a silly question, but I cannot find a simple answer...
I need to trigger a link with href via an external function, i.e.
<div onclick="linkClick()">Emulating click</div>
<a id="test" href="flash/pdfs/test.html" >my link</a>
function linkClick(){
$("#test").click();
}
It does not work and returns nothing. I understanbd that it is because
the a#test does not have the actual onclick event. So, how can I
emulate click on a#test?
Note, that I cannot modify the a link element or add onclick events.