- Functions
- DOM - Document Object Model
- Forms
- Event Handlers
A function in JavaScript is similar to a mathematical function. A mathematical function receives arguments, performs a calculation, & returns an answer
A JavaScript function might receive arguments, will perform a calculation, & might return an answer
The syntax for calling a function;
function-name(zero-or-more-arguments-separated-by-commas);
Syntax
The declaration statement var msg;
-has msg as a variable
Assignment operator ( = )
assigns the value at the right into a variable at the left
An object is an entity that represents something tangible.
document
object's behaviors is its ability to retrieve an element using the element's id
valuegetElemementById
method e.g., document.getElementById("message")
In executing the method call, the JavaScript engine searches for an element with id="message"
The DOM models all of the parts of a web page document as nodes in a node tree
A node shows web page elements that include other elements and (text & attributes)
Each node represents either;
Root node - a node at the top of a tree
Dynamic HTML - refers to updating the web page's content by manipulating the DOM's nodes. Some of the options includes;
document.getElementById(id).innerHTML
- changes contents of a given elementdocument.write()
- write directly to the HTML output contentdocument.getElementById(id).attribute
- changes the value of the src attribute of a given elementdocument.getElementById(id).outerHTML
- changes contents of the entire elementdocument
in your code and then use the root object as a starting point in traversing down the treeinteracted with (e.g. a button that was clicked)
and use that node object as a starting point in traversing up or down the treedocument
object's getElementById
method with the element's id value as an argumentA form is a mechanism for grouping input controls (e.g., buttons, text controls, and checkboxes) within a web page
To make forms useful, we use JavaScript to to read the user's input, process it, and display the results
Form's input data processing uses 2 strategies
Form elements are in charge of grouping form's controls
onclick
attribute is known as an event-handler attribute because its value is an event handler
An event handler is JavaScript code that tells the JavaScript engine what to do when a particular event takes place
Queries about this Lesson, please send them to:
*References*
- Google Maps; Power Tools for Maximizing the API, 2014
Evangelos Petroutsos
- D3 Tips and Tricks; Interactive Data Visualization in a Web Browser, 2013
Malcolm Maclean
- Interactive Data Visualization for the Web, 2013
Scott Murray
- Leaflet Documentation
- Google Documentation for developers
Courtesy of …