Currently, I am dealing with pre-existing code that is automatically generated and needs to adhere to a specific format:
<div id="TITLE1"></div>
<div id="div-1"></div>
<div id="div-2"></div>
<div id="div-3"></div>
<div id="div-4"></div>
.... (there can be more divs here, IDs can vary as well) ...
<div id="TITLE2"></div>
My current objective involves the following tasks:
- Enable
TITLE1
to be clickable - Upon clicking, hide all subsequent
DIVs
(not nested and unable to nest) - If
TITLE1
is clicked again, display the previously hiddenDIVs
- Only conceal those
DIVs
that directly follow aTITLE
until the nextTITLE
(exclusive)
The preferred resolution allows for the utilization of jQuery or similar frameworks.