How do I click this using JavaScript?
The "a" only have href and only id on the "div"
<div id="id">
  <a href="link">
    </a>
  </div>How do I click this using JavaScript?
The "a" only have href and only id on the "div"
<div id="id">
  <a href="link">
    </a>
  </div> 
    
    Here I've just made the a-link, do a console.log().
But if the onclick is left off, and the url didn't have a hash it would still be ok. It's just the console.log() is better way of seeing what's happening inside a snippet.
document.querySelectorAll('A')[0].dispatchEvent(
  new MouseEvent('click', {
    'view': window,
    'bubbles': true,
    'cancelable': true
  })
);<div id="id">
  <a href="#" onclick="console.log('link clicked')">123
  </a>
</div> 
    
    put javascript: before your function name then it will call your js function.
<div id="id">
  <a href="www.google.com" id="myLink">
  </a>
</div>
in your js code.
$("myLink").click();
