Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Triggering An Event Programmatically With JavaScript

 			  const btn = document.querySelector('.btn');

			   btn.addEventListener('click', function () {
			          alert('You clicked a button');
			   });

			  const clickEvent = new Event('click');
			  btn.dispatchEvent(clickEvent);
	
 
PREVIOUS NEXT
Tagged: #Triggering #An #Event #Programmatically #With #JavaScript
ADD COMMENT
Topic
Name
3+1 =