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

CSS Flex, Grid + JS (JQery code)

Yann 190

@neuyann

Desktop design screenshot for the FAQ accordion card coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


PFewww ... this one was a real challenge... It took so long for me to display correctly the images and the small arrow icons... (which I know I didnt use the correct solution to display).

And, I did my first code in JS.. Quite hard I'd say! There's a problem when i click on the text do display the paragraph down, I need to click two times for it to work. I don't understand why.

Can someone help me to improve my code here? I do need it... Be indulgent, Im just starting coding... Thanks

[UPDATE] I used jQuery for the accordion effect, but how to turn the arrow down in this cas?

Any advice?

Community feedback

P

@12Kentos

Posted

Hey @neuyann,

Nice job on finishing this challenge especially with it being the first one you used Javascript on!

If you check out jQuery, I would suggest you keep working on learning vanilla Javascript as well. Yes jQuery is easier, but the better you know vanilla Javascript, the easier jQuery will be to use, and you will be able to do things people who only know how to use jQuery won't be able to do. ;)

As for the Javascript, have you heard about event listeners? If not I would suggest you look into them, as I was able to complete the challenge with the following Javascript.

`const faqs = document.querySelectorAll(".faq-card__text__container");

faqs.forEach((faq) => { faq.addEventListener("click", () => { faq.classList.toggle("active"); }); });`

copy and pasting this into your project wouldn't work, as my html is structured differently. However I'd be happy to help find some good places to learn more about event listeners, how they work and what not. Feel free to check out my solution to the project, and compare. :)

My Solution

Keep up the great work!

Marked as helpful

0

@covstar

Posted

Have you tried using jQuery. It's much easier than vanilla JavaScript. For example if you want the paragraph to display on click:

HTML:

<div class ="first-paragraph"> <div class="first-heading> <p> your heading to be clicked on</p> </div> <div class="inner-content> <p> paragraph to show or hide on click</p> </div> </div>

JavaScript:

$(document).ready(function (){ // Click on the heading to perform a function $('.first-heading').click(function (){

// Will slide the content up or down when clicked once $('.inner-content').slideToggle(); });

})

I hope this is helpful?

0

Yann 190

@neuyann

Posted

@covstar Thanks for your advice, I'll check jQuery so :) .

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