Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:55:37+00:00 2026-06-14T12:55:37+00:00

I have the same element: <div id=demo_div style=display:none;></div> on both page1.html and page2.html .

  • 0

I have the same element:

<div id="demo_div" style="display:none;"></div>

on both page1.html and page2.html.

The JavaScript has access both to page1.html and page2.html. When I access element with

$("#demo_div")

I get element that is the first in the DOM (page1.html and page2.html are tabs of index.html, so one of them is hidden but always exist in the DOM).

Is that possible to get the element from a particular page?

UPDATE 1:

The entire HTML:

<html>
<html lang="us">
<head>
    <meta charset="utf-8">
    <title>Test Index Page</title>

    <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
    <META HTTP-EQUIV="Expires" CONTENT="-1">

    <link href="css/styles.css" rel="stylesheet">
    <script src="js/jquery-1.8.2.js"></script>
    <script src="js/jquery-ui-1.9.0.min.js"></script>

    <script src="modules/page1.js?version=5"></script>
    <script src="modules/page2.js?version=5"></script>
</head>
<body>
<div id="wrap">
    <div id="content" style="display:none;">
    <div id="main_tabs">
        <ul id="tabs_header">
            <li><a href="#Home">Home</a></li>
            <li><a href="modules/page1.html?version=3">Page1</a></li>
            <li><a href="modules/page2.html?version=14">Page2</a></li>
        </ul>
    </div>
    </div>
</div>
</body>
</html>

UPDATE 2:

I can’t have unique IDs because I use .load for loading page2.html as hidden part of page1.html thus I will have duplicate elements.

UPDATE 3:

I run the JavaScript from within a .js file that is linked to index.html so it has access to its siblings (page1.html and page2.html).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:55:38+00:00Added an answer on June 14, 2026 at 12:55 pm

    Just in case someone missed it. The problem can be solved using dynamically added classes when you know what page is loading. Just add a class to the div:

    $('myDiv').addClass('page' + thePageNr);
    

    Nevertheless: Remove the duplicate IDs, they will produce unexpected behaviour 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table which is inside of a div element and I
For example I have simple html. <body> <div class=a> <div class=child></div> <!-- div element
I want to have the same functionality of select in HTML but using div
Why does an html element (such as a div) that has been styled with
I have a situation where all my selectors all have the same ancestor element
I have a mouseDown event and a click event on the same element. When
I have scenario where I have to use the same XSD element for different
I have several of the same class of element on a page and am
Is it ok to have id names for children of an element the same
I have a canvas element positioned absolutely over a Flash object of the same

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.