On my page, most of the p-sections are hidden under the heading h3. If you click on them, the contents will be shown below. When you open the page, only the first section is displayed. I use jQuery to hide this section, for example:
jQuery("#area h3:first").addClass("active");
jQuery("#area p:not(:first)").hide();
But what if there is an anchor in one of the other sections and the user contacts C # at the end of the URL? Right now, it jumps to a hidden section, which is annoying because the text is not displayed. I would not want to hide the section when the anchor in the URL is in that section, for example. http://domain.com/page.php#anchor_in_section_3 .
How to prevent hide / collapse a section?
More: After answer 1, I found two problems: if you use .hide and .show only one line of code later, sections remain hidden. This works fast for jQuery. Another problem is that with the solution described in answer 1, jQuery only finds the binding if it is not in the child tag.
This is harder than I thought :)
Thus, the solution described in words is that all sections except the first and those that contain the anchor tag should be hidden. An anchor can be in any (child) type of section.
Tried 2 hours to pass this into jQuery but unsuccessfully with my white jQuery knowledge.
Gerob source
share