Navigate to another HTML division using data-toggle

I have 2 HTML documents

index.html and services.html

In services.html, I have the following code:

<a class="nav-link" data-bs-toggle="tab" href="#ds-tab">Data Science</a>
<a class="nav-link" data-bs-toggle="tab" href="#ai-tab">AI</a>

<div class="tab" id="ds-tab">
   <p>DS section </p>
</div>

<div class="tab" id="ai-tab">
   <p>AI section </p>
</div>

The above code works correctly in services.html.

However, if I am on index.html and include a link like this:

<a href="services.html#ai-tab">AI Section</a>

The link doesn't display the targeted div after navigating to the page.

I also tried using this approach but it didn't work either:

<a data-bs-toggle="tab" href="services.html#ai-tab">AI</a>

Answer №1

Include a unique identifier in the AI Section link by adding a data-target attribute with the value set to the id of the ai-tab div:

<a data-target="#ai-tab" href="services.html">AI Section</a>

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

Revoke the prior invocation of the Google Maps geocoding function

While working on implementing an autocomplete with JavaScript and the Google Maps geocode method (using the keyup event on input), I have encountered a problem where I sometimes receive the results of the previous search instead of the current one. I am l ...

Bug in Async.js causes unexpected results in loop involving numbers

When attempting to reference a variable in a for loop using the Async Library for Node.js, it seems to not work as expected. Here is an example: var functionArray = [] , x; for(x = 0; x < 5; x++) { functionArray.push(function (callback) { conso ...

Is your preference selecting made a breeze by dragging the input field?

Looking to create a form that allows users to indicate their preference between Option A and Option B by dragging a slider. I know there must be a library out there that already does this, but I can't seem to figure out what it's called to searc ...

Navigating PopUpWindows using SeleniumIn this guide, learn the best

I have attempted to manage a particular PopUp / new Window in Java using SeleniumServer, but unfortunately, it is not functioning as expected. Here is what I have tried: selenium.click("css=a[title=\"Some irrelevant title\"] > div.text"); Thr ...

Tips for extracting innerHTML or sub-string from all elements that have a specific class name using JavaScript

When it comes to shortening the innerHTML of an element by its Id, I have found success using either slice or substring. While I'm not entirely clear on the differences between the two methods, both accomplish what I need them to do. The code snippet ...

Update to the viewport meta tag in iOS 7

Anyone experiencing problems with the viewport tag after updating to iOS7? I've noticed a white margin on the right side of some sites. Adjusting the initial scale to 0.1 fixed it for iPhone but made it tiny on iPad 3, which is expected due to the low ...

Is there a way to create a table with "cells that can be controlled individually" similar to the image provided using HTML and CSS?

I have been searching online for solutions on how to create a table similar to the one in this image, but so far I haven't had much luck. I attempted to use colspan, however, it didn't yield the results I was hoping for. Does anyone have any alt ...

Maximizing the Use of Multiple Conditions for Styling in AngularJS

I have a table where I need to set different colors based on the values in one of the columns. I've successfully managed to set two colors using NgClass, but I'm unsure how to set up three different conditions. <scri ...

Creating blinking or flashing text using CSS 3 is a fun way to add eye-catching animation

Here's the current code I'm using: @-webkit-keyframes blinker { from { opacity: 1.0; } to { opacity: 0.0; } } .waitingForConnection { -webkit-animation-name: blinker; -webkit-animation-iteration-count: infinite; -webkit-animation-timi ...

Restore the button to its original color when the dropdown menu is devoid of options

Is it possible to change the button colors back to their original state automatically when a user deselects all options from my dropdown menu? The user can either uncheck each option box individually or click on the "clear" button to clear all selections. ...

Learn the method to duplicate Outer HTML with the use of jQuery or Pure JavaScript

I have successfully copied the value of an input into the clipboard using the first part of the solution provided. However, I am now trying to figure out how to copy HTML content like an entire <p> tag. Currently, when attempting this, I am encounter ...

Is it possible to leverage the flex features of react-native in a manner similar to the row/column system of

Is it a good idea to utilize flex in react native by creating custom components that retrieve flex values? I previously used the bootstrap grid system and now I am exploring react native. Is there a way to implement this example using react-native bootstr ...

Having troubles with angular due to doodle throwing errors?

https://codepen.io/tuckermassad/pen/rPYNLq I took the CSS doodle code from the above link and incorporated it into my angular component: <section class="main"> <css-doodle grid="5"> :doodle { @grid: 10 / 100%; } ...

Is it possible to retrieve all data stored in AsyncStorage using React Native, while excluding the

In my current implementation, I am utilizing AsyncStorage.setItem() to store a string key and JSON object in AsyncStorage. For example: https://i.sstatic.net/qjiCD.png However, upon retrieving data from AsyncStorage using getAllKeys() and multiGet(), it h ...

Unlocking Worldwide Availability for Identifying URL Parameters

Is there a way to obtain global access to the current URL ID params? I am facing difficulty accessing the current URL ID in a child component within React. The ID is essential for querying a MongoDB database in my ChecklistTool component. Typically, I wou ...

Discovering the initial element in an array that meets a condition by employing an asynchronous function

I'm facing a rather peculiar issue. I need to locate the first element in an array that meets a certain condition, but the find function must be labelled as async because a promise is required for the search. Just to clarify, the code provided below ...

What is the best way to incorporate modal window parameters into this code snippet?

JavaScript function: function loadBlockEditor(block, username) { var blockInfo = $.ajax({ url: "in/GameElement/BlockEditor.php", type: "GET", data: 'block=' + block + '&nick=' + username, dataType: "html" }); b ...

Retrieve a distinct property of an element from an array of objects fetched from an API using Vue 2

I successfully retrieved an array of objects from an API in mounted within Vue. The array consists of various objects with properties such as author, genre, poster, title, and year. 0: author: (...) genre: ("Rock") poster: (...) title: (...) year: (...) 1 ...

Encountering issues with reading undefined properties while working with react-chartjs-2 and chart js

Having trouble with react chartjs errors? Visit the link for more details https://i.stack.imgur.com/lI2EP.png The versions I'm using are ^3.5.0 for chart.js and ^4.0.1 for react-chartjs-2 Tried downgrading to version 2 but it didn't solve the ...

Versatile WordPress theme offering a variety of vibrant color options

Currently in the process of creating a WordPress theme, I am interested in incorporating various color schemes. After conducting research on both free and premium themes, it became apparent that different approaches are taken to achieve this feature. Wha ...