Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Erwan EL
7,669 Pointsfunctions whith display none and display block chaining
Hi everybody
I'm a little confuse maybe anyone can help i have this:
#element {
animation-duration: 0.8s;
animation-name: fadeIn;
}
and some javascript
function none () {
#element.style.display = 'none';
}
function block() {
#element.style.display = 'block';
}
My problem is that if i launch individualy each functions in my browser console the element hide then show whith the fade in as i want, but if i'm chaining both functions like this:
none();
block();
the fade in doesn't work anymore.
I kind of understand why but how can i chain my functions and keeping the fade in?
1 Answer
Erwan EL
7,669 PointsI resolve this problem doing this:
none()
setTimeout(() => {
block()
}, 0)
Not so clean i guess but working great.