JQuery - a manual trigger link inside a <div> clicked on
Possible duplicate:
How can I simulate binding using jquery?
For some reason, I thought it would be very simple. Here is my code:
$('#someDamnedDiv').live('click', function () { $('a', this).trigger('click'); }); What is Sam Hill wrong about my function?
+6
asfsadf
source share2 answers
I do not think that you can simulate a click on a link. Take a look here . However, you can do this:
$('#someDamnedDiv').live('click', function (event) { window.location = $(this).find('a').attr('href'); event.preventDefault(); }); +7
cambraca
source sharethis is what i use for one of my projects:
$('div.classname').click(function(e){ if($(e.target).is('a')) return; $(this).find('a').click(); }); +4
code90
source share