Simulate a click on <a> element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

Simulate a click on <a> element

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
window.onload = function() {/*from   ww w .  jav  a 2s  .c om*/
    document.getElementById("gift-close").click();
};

      </script> 
   </head> 
   <body> 
      <a id="gift-close" href="javascript:void(0)" class="cart-mask-close p-abs" onclick="console.log('Test worked');" rel="coupon">&nbsp;</a>  
   </body>
</html>

Related Tutorials