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
Aurelian Spodarec
10,801 PointsAdding class to the target element from many
HI,
I have the li with the class, and on click, I'm trying to set up to the specific one class 'is-active'.
Tried few things, but can't get this working. What's wrong with it?
Heres the Codepen
2 Answers
Aurelian Spodarec
10,801 PointsOkay.
SInce I'm doing the bubling effect, I clicked on the image, which is in the li.
Since I'm getting the target event, the list item, the click will get to the image. To get to the li, I need to parent node one time.
That's why it didn't work.
Henrik Christensen
Python Web Development Techdegree Student 38,322 PointsGetting a lot of cannot read property of null on line 11:
var btnHamburger = document.querySelector('.site-header__hamburger');
Also getting a lot of warnings because you're requesting pictures from http.
I don't know if any of those 10 errors and 20 warnings is the problem, but you might want to fix 'em :-)
Aurelian Spodarec
10,801 PointsWell, on local enviroment I don't have any errors or warning. It's probably because of codepen enviroment.
The hamburger menu works well.
Not sure what's the issue here.
Aurelian Spodarec
10,801 PointsOh. It can't read the property of null because I didn't put the menu in the HTML.
However, that doesn't matter. The code below should work anyway.
Aurelian Spodarec
10,801 PointsWHy does this work on codepen? Exactly same code, but it doesn't work on my local enviroment eh xd