The first function should have an “if-else” condition. When the user clicks on the link, the condition should check whether the content is already expanded or not. If the content is already expanded, it should hide the content by changing the style property of the element to “none”. If the content is not expanded, it should show the content by changing the style property of the element to “block”.
Adding HTML Elements
To add the expand and collapse element, you need to add two HTML elements. The first one is a link with the id “expand”, and the second one is a div with the id “content”. The div should contain the content that you want to expand and collapse.