Anonymous function example 20 window onload = function() { var okButton = document getElementById("ok"); okButton onclick = okayClick; };
window onload = pageLoad; Anonymous functions (8 1 2) function(parameters) { statements; } JavaScript allows you to declare anonymous functions
window onload = function(){ assert( getOpacity( document getElementById("opacity") ) == "0 5", "Get the current opacity of the element " ); };
JS HTML code now has no JavaScript code for "onclick" window onload event is set to an anonymous function that sets the onclick for the button
Anonymous function example window onload = function() { var ok = document getElementById("ok"); ok onclick = okayClick; }; function okayClick() {
window onload = functionName; // global code // this will run once the page has finished loading function functionName() { element event = functionName;
when you interact with the element, the function will execute □ onclick is just one of many event HTML attributes □ but popping up an alert window is
What is the document structure, which elements are contained defining an anonymous function, and keeping a reference to // its function object
An anonymous function (the $ function) with one parameter that returns a DOM element Slide 11 var $ = function (id) { return document getElementById(id); }