const faqItems = document.getElementsByClassName("faq-question");
const faqContents = document.getElementsByClassName("faq-content");
for (item of faqItems) {
item.addEventListener('click', (e) => {
// CLOSE ALL FAQS
for (let i=0; i<faqContents.length; i++) {
faqContents[i].style.display = 'none'
}
// OPEN THE CLICKED FAQ
e.target.nextSibling.nextSibling.style.display = 'block'
})
}
.faq {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 0 auto;
padding: 60px 90px;
background-color: black;
border-bottom: 10px solid #222;
color: white;
}
.faq-title {
font-size: 50px;
line-height: 55px;
font-weight: 700;
color: white;
text-align: center;
}
.faq-list {
width: 65%;
text-decoration: none;
list-style: none;
}
.faq-item {
display: block;
margin-bottom: 10px;
}
.faq-question {
width: 100%;
text-align: left;
border: 0;
margin-bottom: 2px;
position: relative;
background-color: #303030;
color: white;
font-weight: 500;
font-size: 25px;
padding: 25px;
cursor: pointer;
}
.faq-question svg {
width: 40px;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 16px;
cursor: pointer;
}
.faq-question svg path {
fill: white;
}
.faq-content {
display: block;
text-align: left;
border: 0;
margin-bottom: 2px;
background-color: #303030;
color: white;
font-weight: 500;
font-size: 25px;
padding: 25px;
display: none;
}
.member h2 {
font-size: 20px;
font-weight: 400;
text-align: center;
}
.member .email-2 {
width: 100%;
display: flex;
margin-top: 30px;
}
.email-2 input {
width: 68%;
}
<section class="faq">
<h1 class="faq-title"> Frequently Asked Questions </h1>
<ul class="faq-list">
<li class="faq-item">
<button class="faq-question">
What is Netflix?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
Netflix is a streaming service that offers a wide variety of award-winning TV shows, movies, anime, documentaries, and more on thousands of internet-connected devices. <br> You can watch as much as you want, whenever you want without a single
commercial – all for one low monthly price. There's always something new to discover and new TV shows and movies are added every week!
</article>
</div>
</li>
<li class="faq-item">
<button class="faq-question">
How much does Netflix cost ?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
Watch Netflix on your smartphone, tablet, Smart TV, laptop, or streaming device, all for one fixed monthly fee. Plans range from ₦1,200 to ₦4,400 a month. No extra costs, no contracts.
</article>
</div>
</li>
<li class="faq-item">
<button class="faq-question">
Where can I watch?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
Watch anywhere, anytime. Sign in with your Netflix account to watch instantly on the web at netflix.com from your personal computer or on any internet-connected device that offers the Netflix app, including smart TVs, smartphones, tablets, streaming media
players and game consoles. <br> You can also download your favorite shows with the iOS, Android, or Windows 10 app. Use downloads to watch while you're on the go and without an internet connection. Take Netflix with you anywhere.
</article>
</div>
</li>
<li class="faq-item">
<button class="faq-question">
How do I cancel?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
Netflix is flexible. There are no pesky contracts and no commitments. You can easily cancel your account online in two clicks. There are no cancellation fees – start or stop your account anytime.
</article>
</div>
</li>
<li class="faq-item">
<button class="faq-question">
What can I watch on Netflix?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
Netflix has an extensive library of feature films, documentaries, TV shows, anime, award-winning Netflix originals, and more. Watch as much as you want, anytime you want.
</article>
</div>
</li>
<li class="faq-item">
<button class="faq-question">
Is Netflix good for kids?
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M23.25 37V24.75H11v-1.5h12.25V11h1.5v12.25H37v1.5H24.75V37Z"/></svg>
</button>
<div class="faq-content">
<article>
The Netflix Kids experience is included in your membership to give parents control while kids enjoy family-friendly TV shows and movies in their own space. <br> Kids profiles come with PIN-protected parental controls that let you restrict the
maturity rating of content kids can watch and block specific titles you don’t want kids to see.
</article>
</div>
</li>
</ul>
<div class="member">
<h2>Ready to watch? Enter your email to create or restart your membership.</h2>
<div class="email-2">
<input type="text" placeholder="Email Address">
<button class="get-started">
Get Started
</button>
</div>
</div>
</section>