Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM A Simple Example

ragai alhariri
ragai alhariri
2,081 Points

It's not Work any help?

<!DOCTYPE html> <html> <head> <title>JavaScript and the DOM</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <h1 id="myHeading">JavaScript and the DOMewfwewfe</h1> <p>Making a web page interactive</p> <script> src="app.js"</script> </body> </html>

const myHeading = document.getElementById("myHeading"); myHeading.addEventListener('click',( ) => { myHeading.style.color = "red";

});

1 Answer

Cameron Childres
Cameron Childres
11,817 Points

Hey Ragai~

You're very close -- it's just that the script tag in your HTML isn't quite right. Move your src attribute inside of the angle brackets and you'll see your JavaScript applied, which works great.

So instead of:

<script> src="app.js"</script>

Do this:

<script src="app.js"></script> 

And a quick tip for the forums: use the markdown cheatsheet linked below the comment box to format your code, makes it much easier to read. Like this:

```html
<code here>
```