Week 07
Multiple JS, DOM, Events and Callback Function
Week6 #7
1. Multiple JS files
You can keep your file in a separate js file.
2. DOM element and Callback Function
Document Object Model (DOM)


<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.dom.min.js"></script>
P5.dom library
Example
Example
Example
Callback function
Callback function is simple that
The function createButton is attached to the variable button.
And when the button is pressed, I want changeColor function os called.
button.mousePressed(changeColor);
Callback is simply one function is called and the other function is continuously called.
var button = createButton("Color??");
button.mousePressed(changeColor);
Example
Assignment
Have multiple .js file (at least 2)
Have DOM element (it can be anything, button, slider, check, wordform, etc)
Last updated