© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
M. SimonJavaScript for Web Developershttps://doi.org/10.1007/978-1-4842-9774-2_8

8. Showing and Hiding Content

Mark Simon1  
(1)
Ivanhoe, VIC, Australia
 

Something you will very often see on web pages is sections that open and close. They may be menu items or sections of content.

In this project, we’ll toggle both content and lists. The technique is similar, which is a matter of having JavaScript change the state of a selected element. For the rest, we will allow CSS to do the job of showing and hiding content, as well as adding a little animation for good measure.

The page we’re working with will be in the Varying Content link and is called showing-hiding.html ...

Get JavaScript for Web Developers: Understanding the Basics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.