Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

anonymous function JavaScript

//! Button Click Event
//! regular function
document.querySelector("button").addEventListener('click', handlClick);

function handlClick() {
    alert("I got clicked!")//just to show it works
  
  //what to do when click detected
}

//!anonymous function
document.querySelector("button").addEventListener('click',function handlClick() {
    alert("I got clicked!")//just to show it works
  
  //what to do when click detected
});
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #anonymous #function #JavaScript
ADD COMMENT
Topic
Name
7+7 =