How to trigger click event without clicking JavaScript | Example Code

  • by

If you want native JS to trigger click event without clicking then use the element id and click() method of JavaScript.

Syntax: JavaScript trigger click on the element


Trigger click event without clicking in JavaScript Example

Complete HTML example code:

Create one button with “trigger” id and assign msg() function to the onClick attribute. If the button clicks then msg() function triggers a popup alert.

	<button id="trigger" onclick="msg()">Auto Click</button>


		function msg(){
			alert("Auto click");



trigger click event without clicking JavaScript

Do comment if you have any doubts or suggestions on this JS event topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.