nNote Camel case is the practice of writing compound words without spaces and capitalizing each word.
For example, in camel case ???load calendar data??? would be written as LoadCalendarData. There are two variations,
upper and lower. In upper camel case, the first word is capitalized (for example, LoadCalendarData);
in lower camel case, the first word is not (for example, loadCalendarData).
Variable names, function names, and object names use lower camel case, whereas classes
normally use upper camel case. A class is anything that gets instantiated with the new keyword.
(You learn all about classes and objects in Chapter 3.)
var element = document.createElement('div');
var object = new XMLHttpRequest();
Event Handling
JavaScript gets executed via an event, which might happen when the page loads, when a user
clicks something, or when the document loads. Code that is not encapsulated in a function or
object gets executed as soon as it is parsed by the browser. Code that is in a function or an
object has to be called via an event handler.
Inline Event Handling
Similar to using the style attribute in CSS, you can apply an event handler to elements
directly in the HTML. Let??™s see a click event for a link:
My LinkWhen you click the link, the function foo() is executed. For elements that have a primary
behavior, such as links or forms, the behavior runs after the event handler has completed its
execution.
Pages:
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90