So adding the click code before the other method will work. First, make a local copy of random-color-addeventlistener.html, and open it in your browser. It's the most powerful method and scales best with more complex programs. The user resizes or closes the browser window. Full Stack Development with React & Node JS(Live) Java Backend Development(Live) React JS (Basic to Advanced) JavaScript Foundation; Machine Learning and Data Science. People, there's only one event handler in the OP's question. Links take you to a certain part of the page, another page of the website, or another website entirely. For some elements, including , the change event doesn't fire until the control loses focus. It allows the programmer to execute a JavaScript's function when an element gets clicked. Thats more comfortable for Mac users. The color of our the text turns blue any time the button is clicked: We could take things a little bit further by changing our text to be more colors: So, what we want to do is change the text to blue, green, and orange-red. Document-relative coordinates: pageX/pageY. You should never use the HTML event handler attributes those are outdated, and using them is bad practice. To understand the fundamental theory of events, how they work in Connect and share knowledge within a single location that is structured and easy to search. Get certifiedby completinga course today!