Design comparison
Solution retrospective
why my javascript code is not running :/
Community feedback
- @MartineauRemiPosted about 3 years ago
Hey !
-
For the button, you have to change the onclick attribute from "myFunction" to "myFunction();'
-
Since you created a variable called 'icon', I think you need to replace
social.style.display
with
icon.style.display
- Also, you're trying to access the div with the class 'social' with the method 'getElementsByClassName'. The problem is that this method returns an array of the elements found having the corresponding class. Either try to access the first element of the returned array:
var icon = document.getElementsByClassName('social')[0];
or you can access it like this (probably better) :
var icon = document.querySelector('.social');
The second method basically means that you're getting the first element having the class 'social'.
Hope that helps :) Happy coding !
Marked as helpful1 -
- @hardy333Posted about 3 years ago
On line 72 and 73 instead of social you should use
icon[0]
. "social" - variable doesn't exists in your code instead you have icon variable which you call itgetElementByClassName("social")
- this thing which itself is HTMLCollection object which is almost like a array that is why you need [0] syntax to reach your real .social
element.Marked as helpful0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord