Possible Duplicate:
How can I simulate an anchor click via jquery?
For some reason I thought this would be really easy. Here's my code:
$('#someDamnedDiv').live('click', function () {
$('a', this).trigger('click');
});
What the Sam Hill is wrong with my function?
I don't think it's possible to simulate a click on a link. Look here. However, you could do this:
$('#someDamnedDiv').live('click', function (event) {
window.location = $(this).find('a').attr('href');
event.preventDefault();
});
this is what i use for one of my projects:
$('div.classname').click(function(e){
if($(e.target).is('a')) return;
$(this).find('a').click();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With