Utilizing identical ID values multiple times to link to the identical location

I am currently working on a horizontal grid project with 3 image squares. My goal is to create an action where clicking on any grid section will anchor the user down to a slideshow box displayed below the grid. Below is an example of one grid section and the slideshow section. Since I can't repeat the same ID tag in HTML, I believe I will need to utilize some JavaScript or jQuery to achieve this functionality. Can anyone provide guidance on how to accomplish this?

<div id="grid-item" class="grid-item grid-item-1">
    <div class="grid-project">
        <img class="profile-image" src="img/image1.png">
    </div>
    <div class="grid-overlay">
        <div class="project-info">
            <a href="#project-link" id="toggle">
                <h4 class="project-name">Headline 1</h4>
                <p class="project-categories">description 1</p>
            </a>
        </div>
    </div>
</div>
<div id="grid-item" class="grid-item grid-item-2">
    <div class="grid-project">
        <img class="profile-image" src="img/image.png">
    </div>
    <div class="grid-overlay">
        <div class="project-info">
            <a href="#project-link" id="toggle">
                <h4 class="project-name">Headline 2</h4>
                <p class="project-categories">description 2</p>
            </a>
        </div>
    </div>
</div>


 <div id="slideshow" class="slideshow">
        <div class="slideshow_inner">
        <a name="project-link" class="anchor">
            <img src="img/slide_img_1.png">
        </div>
    </div>

Answer №1

Ensure each element has a unique ID when using id="". In the second grid, modify the following:

<a href="#project-link" id="toggle">

Change it to:

<a href="#project-link" id="toggle2">

Make sure not to reuse the same ID.

Additionally, in the second section of your HTML, you have used name="" instead of id:

<a name="project-link" class="anchor">

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 there a way to synchronize breakpoint values across different media queries?

Currently utilizing Next.js version 9.53. Utilizing the built-in CSS module support provided by Next.js without the use of CSS pre-processors (less, sass, etc.) or CSS-in-JS (styled-components, etc.). Presently, my approach involves writing CSS in a mobi ...

Mastering the art of creating an authentic carbon fiber CSS background

Authentic carbon fiber consists of a series of interconnected grey fibers that resemble woven sheets in grey color. Does anyone have knowledge on how to replicate this pattern using CSS? The examples created by Lea Verou do not accurately depict true carb ...

Customizing the scrollbar within a modal using reactjs-popup

I am currently working on a CustomPopup functional component that includes a reactjs-popup: function CustomPopup({setFalse, item}){return(<Popup open={true} onClose={() => {setFalse(false)}} modal closeOnDocumentClick nested> {item === "howto ...

Displaying API logs on an Html console

function updateData(e) { const animeName = e.target.value; const apiUrl = `https://nyaaapi.herokuapp.com/nyaa/anime?query=${animeName}`; fetch(apiUrl) .then((res) => res.json()) .then(displayAnimeData); } const inputField = document.getEl ...

Discover the process of creating a dynamic mailto link using AJAX and HTML

One of my tasks involves extracting email addresses from an XML document using AJAX, and then displaying them on a webpage as clickable links for sending emails. Here is a snippet of JavaScript code I am working with: emailobj = listings[i].getElementsBy ...

Using body-parser in an Express router: a step-by-step guide

I'm having trouble with a post API that returns an undefined object when trying to print it in the console. I initially thought I was missing body-parser, but even after adding it, I encountered an error message indicating body-parser deprecated bodyP ...

Failure to trigger Ajax callback function

I am currently working on a form page that will be submitted using Ajax. The steps I have planned are: 1. Use Ajax to check if the email already exists 2. Verify if the passwords match 3. Switch to another "screen" if they do match 4. Final ...

Creating a MongoDB query using Mongoose to simulate JavaScript filtering operations (including filter and every) for searching with multiple terms

Introducing a New Search Feature In my current project, I am implementing a search functionality using MongoDB with Mongoose ODM. The existing codebase already has a search feature using JavaScript. Here is a snippet of the code: terms.every((term) => ...

I am puzzled as to why my code in React is rendering twice without any apparent reason

I ran into a strange issue where my console.log("hi") was being displayed twice. I was working on a simple todo-list project and noticed that everything was getting double clicked. After some troubleshooting, it seems like the code is executing any JavaScr ...

Combining and organizing Javascript files for efficient loading and reusable code functionality

I've been tasked with cleaning up a project that contains around 45-50 separate .js javascript files. I'm trying to figure out the most effective way to reduce their loading size. Should I combine all the files into one using npm or gulp? Or shou ...

Exporting JSON data as an Excel file in AngularJS, including the option to customize the fonts used for the

Currently, I am working on a project where I need to convert JSON data to an Excel file using JavaScript in combination with AngularJS. So far, I have successfully converted the JSON data to CSV format. However, I faced issues with maintaining the font s ...

Access-Control-Expose-Headers configuration not being recognized

When setting up my Apache web server configuration, I made sure to include support for two additional headers that are not part of the standard six: Header set Access-Control-Allow-Origin "*" Header set Access-Control-Expose-Headers: Content-Disposition,X ...

The issue arises with getInitialProps as it fails to pass data to the page component while attempting to retrieve initial information and subsequently modify it using a button

I am currently working on a component located at app\page.tsx in Next.js v13.4.12, and it includes a button. My goal is to have the button trigger the handleClick function when clicked. The issue I'm facing is that the getInitialProps function ...

Toggle visibility of multiple DIVs with identical classes using radio buttons

I'm looking to streamline my use of radio buttons in HTML. How can I implement a single set of radio buttons at the top that will toggle the visibility of all DIVs with the same class on my webpage? <form> <input type="radio" name="csr_sel ...

Loading the JS file after waiting on Lib (IronRouter) causes the HTML not to load properly

Currently, I am utilizing wait-on-lib along with IRLibLoader.load() in conjunction with Iron-Router, following the instructions provided in the tutorial found at: . My objective is to load external javascript code. Below is a snippet of my routing code: R ...

Ways to shift placeholder text slightly to the right within a select dropdown?

Struggling with this issue for hours, I can't seem to figure out how to: Adjust the position of the placeholder text (Search) by 10 pixels to the right in my select component Reduce the height of the field (maybe by 5px) without success. Could someo ...

When trying to search for 'elForm' using the 'in' operator within the context of a "datetime" type, the error "Unable to find 'elForm' in undefined" occurs

I am attempting to implement a datepicker with time options from Element UI. I am encountering an issue within the ElementUI component. It functions correctly if the type option is set as date, but throws an error with datetime. Below is my code snippet an ...

Is it preferable to include in the global scope or the local scope?

When it comes to requiring a node module, what is the best approach? Should one declare the module in the global scope for accuracy and clarity, or does declaring it in the local scope make more sense? Consider the following examples: Global: let dns = r ...

Having trouble positioning the image at the center of the ion-slides

I'm currently working on designing a slide within an ion item. Everything seems to be functioning correctly, however, the image inside the slide is not appearing in the center. <ion-item style="height:45%; padding-left: 0;"> <ion-slides ce ...

The async and await functions do not necessarily wait for one another

I am working with Typescript and have the following code: import sql = require("mssql"); const config: sql.config = {.... } const connect = async() => { return new Promise((resolve, reject) => { new sql.ConnectionPool(config).connect((e ...