Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Custom Event Example

		 const btn1 = document.getElementById('btn1');

			   btn1.addEventListener('boo', function () {
			          alert('Button1 said Boo');
			   });
			   
			   
  			 const btn2 = document.getElementById('btn2');

  			   btn2.addEventListener('boo', function () {
  			          alert('Button 2 said Boo');
  			   });
			   			  const clickEvent = new Event('boo');
			   btn1.dispatchEvent(clickEvent);

			  btn2.dispatchEvent(clickEvent);
 
PREVIOUS NEXT
Tagged: #Custom #Event #Example
ADD COMMENT
Topic
Name
5+1 =