/    Sign up×
Community /Pin to ProfileBookmark

PLease help! :((

Can any of you help me figure out why this code doesn’t work?
I spent 2 hours trying to fix it.
No errors shows up in the console.

HTML

[code]<div class=”logos”>
<div class=”portfolio__button” data-content-target=”#logosContainer”>Logos</div>

<div class=”logos__container” id=”logosContainer” data-portfolio-content>
<div class=”logo-card”>

</div>
<div class=”logo-card”>

</div>
<div class=”logo-card”>

</div>

</div>
</div>

<div class=”illustrations”>
<div class=”portfolio__button” data-content-target=”#illustrationsContent”>Illustrations</div>

<div class=”illustrations__container” id=”illustrationsContent” data-portfolio-content>
<div class=”illustrations__card”></div>
</div>
</div>[/code]

JS

[code]const portfolioButton = document.querySelectorAll(‘[data-content-targe]’);
const content = document.querySelectorAll(‘[data-portfolio-content]’);

portfolioButton.forEach(button => {
button.addEventListener(‘click’, (e) => {
const targetSection = document.querySelector(button.dataset.contentTarget);
targetSection.classList.toggle(‘logos__container-active’);
portfolioButton.classList.toggle(‘portfolio__button-active’);
})
})[/code]

CSS

[code].portfolio__button {
width: 85vw;
height: 70px;
margin: 10px auto;
border: solid 3px black;
cursor: pointer;

display: flex;
justify-content: center;
align-items: center;
font-weight: 800;
font-size: 1.7rem;
}

.logos__container {
width: 80vw;
height: 0;
margin: 0 auto;
background: #333;
overflow: scroll;
}
.logo-card {
width: 250px;
height: 250px;
background: #555;
margin: 10px auto;
}
/*============
Active Clases
============== */
.portfolio__button-active {
border: solid 3px black;
color: white;
background: var(–clr);
}
.containers-active {
width: 500px;
}[/code]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJul 31.2019 — The letter "t" is missing here: `const portfolioButton = document.querySelectorAll('[data-content-targe]');`
Copy linkTweet thisAlerts:
@codyhillauthorJul 31.2019 — @Sempervivum#1606995 Fixed that, but the code is still not working. Now I get cannot read property of toggle in the console.
Copy linkTweet thisAlerts:
@codyhillauthorJul 31.2019 — @Sempervivum#1606995 I manage to make the button be active and unactive but I cant add the class on the dataset.Target
Copy linkTweet thisAlerts:
@codyhillauthorJul 31.2019 — @RaulRogojan#1606998 Fixed it!! The problem was css, not js. the class was width: 500px and it should have been height:500px;
×

Success!

Help @codyhill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.13,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...