TheCarver TheCarver - 6 months ago 49
jQuery Question

jQuery - Imitate Click

I want to imitate an anchor click when a user clicks on the containing

<TD>
but having problems.

This is the JS part:

$('contactTab').click(function() {
$('contactTabLink').trigger("click");
});


And this is the HTML part:

<td class="previewTabs" id="contactTab">
<a class="previewTabLink" id="contactTabLink" rel="#contactOverlay">CONTACT</a>
</td>


When somebody clicks the
<TD>
contactTab, it should trigger a click event on
<A>
contactTabLink which then launches an Overlay. My problem is that the JS function with click listener is NOT firing at all.

Can anybody see where I am going wrong?

EDIT 1:

I have changed the selectors to have #'s but it still won't fire the function.

Answer

Your selector is not correct.

It should be this:

$('#contactTab').click(function() {

   $('#contactTabLink').trigger('click');

});
Comments