Javascript examples for Function:Function Argument
Assign a function and pass parameter at the same time
<!doctype html> <html> <head> <title>atest</title> <script> window.onload=function(){//from ww w. j a v a2 s . c o m var c=document.getElementsByTagName('div')[0].childNodes, l=c.length, filterByClass=function(){ console.log(this.id); }; while(l--){ c[l].onclick=filterByClass; } } </script> </head> <body> <div> <button id="classA">A</button> <button id="classB">B</button> <button id="classC">C</button> </div> </body> </html>