Is it possible to conceal specific sections of a timeline depending on the current slide in view?

For my product tour, I've structured a timeline with 4 main sections, each containing 4-5 subsections. Here's how it looks:

<ul class="slideshow-timeline">
    <li class="active-target-main main-section"><a href="#target">Target</a>
        <ul class="current-section target-sub">
            <li><a href="#target-1">Donor Profiles</a></li>
            <li><a href="#target-2">Segmentation</a></li>
            <li><a href="#target-3">Custom Lists</a></li>
            <li><a href="#target-4">RFM Analysis</a></li>
            <li><a href="#target-5">Wealth Screening</a></li>
        </ul>
    </li>
    <li class="main-section"><a href="#connect">Connect</a>
        <ul class="current-section connect-sub">
            <li><a href="#connect-1">Email Marketing</a></li>
            <li><a href="#connect-2">Social Media</a></li>
            <li><a href="#connect-3">Direct Mail</a></li>
            <li><a href="#connect-4">Welcome Series</a></li>
        </ul>
    </li>
    <li class="main-section"><a href="#convert">Convert</a>
        <ul class="current-section convert-sub">
            <li><a href="#convert-1">Donation Forms</a></li>
            <li><a href="#convert-2">Automated Receipts</a></li>
            <li><a href="#convert-3">Events</a></li>
            <li><a href="#convert-4">Member Mgmt</a></li>
            <li><a href="#convert-5">Moves Mgmt</a></li>
        </ul>
    </li>
    <li class="main-section"><a href="#optimize">Optimize</a>
        <ul class="current-section optimize-sub">
            <li><a href="#optimize-1">Analytics</a></li>
            <li><a href="#optimize-2">Campaigns/Funds/Appeals</a></li>
            <li><a href="#optimize-3">A/B Testing</a></li>
            <li><a href="#optimize-4">Task Management</a></li>
        </ul>
    </li>
</ul>

I'm interested in a JS solution to hide the connect-sub, convert-sub, and optimize-sub sections when the .active-tour div has a class of target-panel.

Although I tried using .css for this, I'm wondering if there's a more sophisticated approach?

$(function() {
if($('.active-tour').hasClass('target-panel')) {
      $(".connect-sub").css("display", "none");
      $(".convert-sub").css("display", "none");
      $(".optimize-sub").css("display", "none");
}
});

Since the timeline and slides are positioned as position:absolute and position:fixed, they don't flow with the page, making it challenging to target them with CSS alone.

In theory, the JS solution should work, but it's not hiding the 3 subsections for some reason, and no errors are appearing. You can view the working page here.

I'll keep exploring a solution, but any guidance you could offer would be greatly appreciated!


Updated to show all subnavs with javascript:

$(function() {
if($('.active-tour').hasClass('target-panel')) {
      $(".target-sub").css("display", "block");
}
});

Answer №1

Revamped response:

To improve the structure, create a div that contains both the main content and the footer timeline. Utilize jQuery to set the class on this outer div and utilize css selectors to display the appropriate submenu items as needed.

check out the updated code snippet here


Initial suggestion:

For a simple solution, you can try the following code snippet:

$('.main-section').on('click',function(){
  $('.main-section').removeClass('active-tour');
    $(this).addClass('active-tour');
});

.current-section{
  display:none;
}
li.active-tour .current-section{
  display:block;
}

see the code in action on this fiddle

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

javascript issue with showing content on click

I'm currently working on a school assignment where I am using the onclick() function to display information about an object. However, I am facing an issue where the information is not popping up as expected. HTML <!DOCTYPE html> <html> ...

Implementing an alert box upon redirect with PHP

This question is pretty straightforward. I have a form on my index.html page and PHP code to submit that form to an external URL, then redirect back to the index: <?php Echo "<style>body{background:#3e4744}</style>"; Echo "<style>h2{ ...

Javascript: Uncaught TypeError - Unable to assign value to non-existent property

I am having an issue with assigning a value to a textbox, and I keep getting this error. Here is my code: This is the textbox in question: <input id="Text1" type="text" runat="server"/> Here is the dropdown list used in the function: <select i ...

Personalize the bootstrap-vue styling within your Nuxt project

Currently, I am working on a nuxt project and utilizing bootstrap-vue as a styling module for my components. I am unsatisfied with the default styles provided and wish to incorporate some customization. Specifically, I aim to modify the appearance of the ...

Is it possible to customize individual CSS attributes for a section within a webpage's layout using a view?

When I render a partial 'calendar/show' in two different views, I'm facing an issue. In view A, everything looks perfect with the right font sizes, but in view B, the font size appears too large. I'm looking for a way to adjust the fon ...

Basic AJAX GET query is currently in a state of "pending."

I've been struggling to figure out why my simple AJAX GET request isn't working as expected. I have a request set up to tell the server to delete a document in a database, and although I receive confirmation that the document has been deleted, th ...

What is the reason behind AngularJS recognizing the $index directive and not the $parent directive?

I have been working on this up until now. Check out my code here. I'm trying to access $parent.$index in a directive, is that possible? Can someone explain it to me? <ul> <li ng-repeat="item in lists"> {{item.name}} ...

In React components, encountering "cannot read properties of undefined" error occurs, whereas it functions perfectly fine within the getStaticProps

I am currently in the process of setting up a blog using Node.js, React, and graphql. Despite being new to these technologies, including Java and Typescript, I am seeking assistance from anyone who may be able to help. My current roadblock involves display ...

Issue with integrating Contact Form 7 HTML into Wordpress

I've revisited this question with a new "input" HTML tag Despite changing everything, CSS still isn't being applied. HTML Code : <form action="#" class="contact-one__form row"> <div class="col-lg-6"> ...

The MUI Grid design features information displayed on the left side, accompanied by an image placed directly to the right

In the React MUI V5 sample code below, I am creating a profile page layout with details of a person displayed on the left side of the page in label/value format. My question is how to position an "IMAGE" entry (assume it's a 300px x 300px profile ima ...

You can interact with our dropdown menu using the tab key, even when it is

We are looking to make our dropdown tabbable when expanded and non-tabbable when collapsed. We attempted using tabindex="-1" on the content inside the expandable div, but this resulted in it being non-tabbable even when expanded. Any suggestions on how t ...

Adding text after a div in React-JS using Bootstrap: A quick guide

Just starting out with website development and I have a question. As I practice making this website, I am struggling to figure out how to add the text "To know more about us click here" below the 'Get started' button. I tried adding a simple < ...

Executing a script that has been inserted into the page post-loading

I'm facing an issue where the script tag at the bottom of my project is not being executed after adding new pages later on. Main const fetch = (url, call) => { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if ...

What is the best way to retrieve the second element based on its position using a class name in Jquery?

DisablePaginationButton("first"); The statement above successfully disables the first element that is fetched. DisablePaginationButton("second"); ===> not functioning function DisablePaginationButton(position) { $(".pagination a:" + position).ad ...

jQuery and CSS3 for importing and customizing text files

I successfully customized the file input utilizing jQuery and CSS3. However, there is one aspect I couldn't quite figure out. After the user selects an image or file, I want to display the selected file's text at the very bottom of the text like ...

Want to learn how to display a description below a photo when you hover over it in a photo gallery?

I am currently creating a basic photo gallery where hovering over a thumbnail displays an enlarged photo below it. My goal is to also have text displayed inside a white text box when hovering over each thumbnail, with unique descriptions for each. I need ...

The function documents.getElementsById() is hindering the effectiveness of Javascript validation

I'm facing an issue with this code. If I uncomment the specific line, the form bypasses validation and goes directly to the linked page in the action attribute. However, if I keep it commented out, the validation runs smoothly, and the alert box displ ...

Tips for preventing browsers from losing style information stored in inputs

https://i.sstatic.net/ab9nF.jpg My custom input field has unique CSS styles applied to it, but unfortunately, when the browser auto-fills the information in those fields, the styles get reset. ...

I possess a list of unique identifiers and require the ability to either update an existing object within an array contained in a MongoDB document, if it exists,

I am facing a challenge in updating a specific element within an array in a MongoDB document. I have multiple IDs of that array and need to update the matching element using those IDs. data= [ { "planId" : "plan_FVNvrmjWT7fRDY", "startTime": ...

Invoke an Ajax function to trigger another Ajax function once complete

var App = { actionRequest: function (url,data,callback){ var that = this; $('#menu').panel('close'); $.mobile.loading('show'); $.when( $.ajax({ method: 'POST', url: ur ...