--- id: 587d7fad367417b2b2512be1 title: Handle Click Events with JavaScript using the onclick property challengeType: 6 --- ## Description
You want your code to execute only once your page has finished loading. For that purpose, you can attach a JavaScript event to the document called DOMContentLoaded. Here's the code that does this:
document.addEventListener('DOMContentLoaded',function() {

});
You can implement event handlers that go inside of the DOMContentLoaded function. You can implement an onclick event handler which triggers when the user clicks on the element with id getMessage, by adding the following code:
document.getElementById('getMessage').onclick=function(){};
## Instructions
Add a click event handler inside of the DOMContentLoaded function for the element with id of getMessage.
## Tests
```yml - text: Your code should use the document.getElementById method to select the getMessage element. testString: 'assert(code.match(/document\.getElementById\(\s*?(''|")getMessage\1\s*?\)/g), ''Your code should use the document.getElementById method to select the getMessage element.'');' - text: Your code should add an onclick event handler. testString: 'assert(typeof document.getElementById(''getMessage'').onclick === ''function'', ''Your code should add an onclick event handler.'');' ```
## Challenge Seed
```html

Cat Photo Finder

The message will go here

```
## Solution
```js // solution required ```