Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Article-preview component

@mahnoork18

Desktop design screenshot for the Article preview component coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


why my javascript code is not running :/

Community feedback

@MartineauRemi

Posted

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 helpful

1
hardy 3,660

@hardy333

Posted

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 it getElementByClassName("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 helpful

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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