Coordinating several navigation tabs and navigation bars in Bootstrap 4 to work together seamlessly

I am in the process of developing a tool that will assist my colleagues in reviewing and comparing information. I aim to present this information consistently for each order, with multiple groups of information per order accessible through nav-tabs. I would like all selector bars to update when a user clicks on any one of the tab selectors, rather than just the clicked one.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <div class="container">
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class='col-md-12'>
        <div class='row'>
          <div class='col-md-12' style='margin-top: -50px;'>
            <ul class='nav nav-pills'>
              <li class='active'><a data-toggle='tab' href='.TabA'>Tab A</a>

              </li>
              <li><a data-toggle='tab' href='.TabB'>Tab B</a>

              </li>
              <li><a data-toggle='tab' href='.TabC'>Tab C</a>

              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="tab-content">
        <div id='TabA1' class='tab-pane fade in active TabA'>
          <div class='row'>aaaaaaaa11111111111</div>
        </div>
        <div id='TabB1' class='tab-pane fade TabB'>
          <div class='row'>bbbbbbb11111111</div>
        </div>
        <div id='TabC1' class='tab-pane fade TabC'>
          <div class='row'>cccccccccc1111111</div>
        </div>
      </div>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class='col-md-12'>
        <div class='row'>
          <div class='col-md-12' style='margin-top: -50px;'>
            <ul class='nav nav-pills'>
              <li class='active'><a data-toggle='tab' href='.TabA'>Tab A</a>

              </li>
              <li><a data-toggle='tab' href='.TabB'>Tab B</a>

              </li>
              <li><a data-toggle='tab' href='.TabC'>Tab C</a>

              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="tab-content">
        <div id='TabA2' class='tab-pane fade in active TabA'>
          <div class='row'>aaaaaaaa22222222</div>
        </div>
        <div id='TabB2' class='tab-pane fade TabB'>
          <div class='row'>bbbbbbb222222222</div>
        </div>
        <div id='TabC2' class='tab-pane fade TabC'>
          <div class='row'>cccccccccc2222222</div>
        </div>
      </div>
    </div>

If one selects any selector bar button, both tabs should be updated accordingly. Currently, only the selected tab is changing while the unselected one remains the same. Is there a solution to address this issue?

Answer №1

You should update the href value and tab in each class. It's a bit complicated to explain, so please refer to my solution below.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
    <div class="container">
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class='col-md-12'>
        <div class='row'>
          <div class='col-md-12' style='margin-top: -50px;'>
            <ul class='nav nav-pills'>
              <li class='active'><a data-toggle='tab' href='.TabA1'>Tab A</a> <!--UPDATE HREF-->

              </li>
              <li><a data-toggle='tab' href='.TabB1'>Tab B</a>

              </li>
              <li><a data-toggle='tab' href='.TabC1'>Tab C</a>

              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="tab-content">
        <div id='TabA1' class='tab-pane fade in active TabA1'> <!--PUT SAME VALUE AS IN HREF-->
          <div class='row'>aaaaaaaa11111111111</div>
        </div>
        <div id='TabB1' class='tab-pane fade TabB1'>
          <div class='row'>bbbbbbb11111111</div>
        </div>
        <div id='TabC1' class='tab-pane fade TabC1'>
          <div class='row'>cccccccccc1111111</div>
        </div>
      </div>
      <p>&nbsp;</p>
      <p>&nbsp;</p>
      <div class='col-md-12'>
        <div class='row'>
          <div class='col-md-12' style='margin-top: -50px;'>
            <ul class='nav nav-pills'>
              <li class='active'><a data-toggle='tab' href='.TabA2'>Tab A</a>

              </li>
              <li><a data-toggle='tab' href='.TabB2'>Tab B</a>

              </li>
              <li><a data-toggle='tab' href='.TabC2'>Tab C</a>

              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="tab-content">
        <div id='TabA2' class='tab-pane fade in active TabA2'>
          <div class='row'>aaaaaaaa22222222</div>
        </div>
        <div id='TabB2' class='tab-pane fade TabB2'>
          <div class='row'>bbbbbbb222222222</div>
        </div>
        <div id='TabC2' class='tab-pane fade TabC2'>
          <div class='row'>cccccccccc2222222</div>
        </div>
      </div>
    </div>

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

Is it possible to use window.print() to print the entire contents of a DIV with both horizontal and vertical scroll bars?

In my code, I have a div that contains both horizontal and vertical scrollers. Whenever I try to print the content inside this div using the window.print() method, it only prints the visible portion of the div. Here is the code snippet that I have attempte ...

Enhance the "content switcher" code

I have been working on improving my "contenthandler" function. It currently changes different articles when I click different buttons, which I am satisfied with. However, I believe there may be a better approach to this and would appreciate any advice on h ...

Retain the existing HTML files of the old website on the webserver while preventing search engines from indexing them

Recently, I completed a website for a client who is looking to replace their ancient HTML hard-coded website. The challenge lies in the fact that they wish to preserve the old website and its files on the web server at their current location. While this do ...

Creating an element that remains in a fixed position in relation to its parent container, rather than the entire screen - here's how

Encountering an issue where, upon user scrolling down, a portion of the sidebar becomes fixed in position. However, when attempting to apply CSS for fixing the sidebar element, it ends up fixed to the entire screen instead of just within its parent contain ...

Locate Checkbox by its Attribute Name and Value

On my webpage, there are multiple groups of checkboxes. In one particular group, I have added a custom "documentcategory" attribute to each checkbox. My goal is to identify all the checkboxes on the page that have the "documentcategory" attribute with a va ...

Achieving Navbar overlap on Carousel with Bootstrap

Is there a way to make the bootstrap navbar overlap with the carousel without causing any issues with #test? HTML <nav class="navbar navbar-expand-lg navbar-dark bg-dark floating-navbar"> <div class="container"> & ...

When using the android phonegap application, the screen interface may not render properly and display a patch on the keypad area when the keypad is

Whenever I tap on a textbox, the system keypad pops up. But after entering text, if I click on any link instead of pressing the Go button on the keypad, the keypad disappears but leaves behind a random area or displays the previous screen. When navigating ...

HTML / CSS / JavaScript Integrated Development Environment with Real-time Preview Window

As I've been exploring different options, I've noticed a small but impactful nuance. When working with jQuery or other UI tools, I really enjoy being able to see my changes instantly. While Adobe Dreamweaver's live view port offers this func ...

Guide on obtaining the file path of an uploaded file through the use of HTML, JavaScript, and PHP

After successfully uploading an image from my drive, I am encountering an issue where I am unable to locate the folder path of that image For example: C:\Images\Logo\Image.png $('#pngfile').change(function (e) { var tmppath = URL ...

Ways to properly close open HTML tags using node.js?

Have you ever encountered a situation where user-entered content from a database or similar source only contains the opening tag without the closing tag? This can disrupt the layout of your website. Is there a way to fix this issue using Node.js on the s ...

What is the process for defining an outcome when a draggable element is placed into a droppable area using Jquery?

Currently, I am working on a task where I need to increase the value of a counter (var counter = 0;) every time a draggable image is dropped into a dropzone, which is also an image rather than a div. $( "#goldbag" ).draggable({ revert: "invalid", containm ...

The chosen options are not appearing. Could this be a problem related to AngularJS?

I am working on setting up a dropdown menu in HTML that includes only the AngularJS tag. This dropdown menu will be used to populate another AngularJS dropdown menu. Below is the code for the first dropdown menu: <select class="form-control" ng-model=" ...

"Choosing the text within an <a> tag: A step-by

I am dealing with the a tag. <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c7dbd9d1f4d9d5ddd89ad7dbd9">[email protected]</a>"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" ...

Incompatibility Issue with Ajax Request on iPad 1 (iOS 5.1.1)

Having an issue with reloading content on my iPad web app. The get request works fine in the browser, but I'm experiencing trouble in Safari on the iPad 1 (iOS 5.1.1). Any suggestions on how to fix this? <script type="text/javascript"> ...

Decode my location and input the address before validating it

While I have come across numerous plugins that enable geolocation and display it on a map, I am searching for something unique. I am interested in implementing geocoding when a user visits the page with an option to "allow geolocation." If the user agrees ...

What is the best way to include spacing among my Bootstrap 5 navigation components?

Looking for advice on creating space between each nav-item in a bootstrap 5 navigation bar while maintaining a clean design for phone mode. Here's the code snippet: <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi ...

Problem with keyframe animations in Internet Explorer 10

My CSS animation works flawlessly in all modern browsers, except for IE10 which is causing some trouble. It appears that IE is having difficulty properly rotating 360deg. I am still searching for a workaround that won't compromise the functionality in ...

How to continuously animate images in HTML using Bootstrap

I want to showcase 7-8 client images in a continuous loop using a <marquee> tag. The issue is that there is a gap between the last and first images. Here is the HTML code I have: <marquee> <ul> <li><a href="#&q ...

Adjust the background color within the border-radius of a designated element

I am currently working on adding a border radius to the bottom of my sections. The background color of my body is set to black. My goal is to have the color under each border-radius match the background-color of the next section, instead of the overall bod ...

Is it possible to insert a button into a specific column of an ngx-datatable within an Angular 8 application?

I am having trouble with this particular HTML code. <ngx-datatable-column name="Option" prop="option" [draggable]="false" [resizeable]="false [width]="250"> <span> <button class="optionButton" type="button" data-to ...