Simulate a click on 'a' element using javascript/jquery


I am trying to simulate a click on on an element. HTML for the same is as follows

<a id="gift-close" href="javascript:void(0)" class="cart-mask-close p-abs" onclick="_gaq.push(['_trackEvent','voucher_new','cart',$(this).attr('rel')+'-mask_x_button-inaction']);" rel="coupon">&nbsp;</a>

How can i simulate a click on it. I have tried


But its not doing anything

This question is tagged with javascript jquery hyperlink click simulate

~ Asked on 2013-07-10 11:04:31

The Best Answer is


Using jQuery: $('#gift-close').trigger('click');

Using JavaScript: document.getElementById('gift-close').click();

~ Answered on 2013-07-10 11:06:39


Using jQuery:


~ Answered on 2013-07-10 11:06:08

Most Viewed Questions: