This article mainly introduces the usage of the anonymous function in JavaScript, and analyzes the function, definition and specific usage of the anonymous function in JavaScript, and the friends who need it can refer to
This example describes the use of anonymous functions in JavaScript. Share to everyone for your reference. The specific analysis is as follows:
JS can not give the function name, but in the use of functions directly through function to the relevant events or variables.
The following JS code to the button set an OnClick event, using the anonymous function
?
1 2 3 4 5 6 7 8 9 |
<form action= "#" > <input type= "button" value= "click Me" id= "Anonbutton"/> </form> <script type= " Text/javascript "> var Anonbutton = document.getElementById (" Anonbutton "); Anonbutton.onclick = function () {alert ("anonymous function called."); </script> |
I hope this article will help you with your JavaScript programming.