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 915553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:54:27+00:00 2026-05-15T17:54:27+00:00

I have web-pages based on widget and I have given all the div the

  • 0

I have web-pages based on widget and I have given all the div the same ID attribute.
After the page is loaded, I want to enumerate all the div element which matches the ID element ‘widget’. I am using jQuery.

Then I want to get the internal div attribute within the ‘widget’ div which shall be used as a tooltip.

<div id="widget" class="span-8  "  >

<h2><a href="">Example.com</a></h2>
<ul>
        <li><h3><a href="example.com">Example News 1</a></h3>
    <div id="tooltip-content">              
        <div class="published">Thu Jul 8, 2010</div>
        <div class="content">
            This detail news 1 shown only on tooltip.. 
        </div>
    </div>
    </li>

    <li><h3><a href="example.com">Example News 2</a></h3>
    <div id="tooltip-content">              
        <div class="published">Thu Jul 8, 2010</div>
        <div class="content">
            This detail news 2 shown only on tooltip.. 
        </div>
    </div>
    </li>               
</ul>

Basically I want to get the all the widgets with id ‘widget'( I have around 20 widgets per page) and get all the div which id matches ‘tooltip-content’ within widget. One widget has 5 or 6 tooltip-content. Can you help me to enumerate the divs?

  • 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-05-15T17:54:27+00:00Added an answer on May 15, 2026 at 5:54 pm

    Technically element id’s should always be unique, yes you can have elements with the same id but you’ll run into problems like this. Where jQuery’s selector engine is only expecting one element with a given id, so what will end up happening is it will find the first element and ignore the rest.

    What you should do is give them all the same class eg

    class="widget"
    

    and the the selector would be

    $(".widget")
    

    EDIT: ah yeah for some reason I thought you mentioned you were using jQuery. but here’s a function that will get all elements by ID that doesn’t require any library’s

    /*
     * ElementsById
     *
     * Author: Diego Perini
     * Updated: 07/12/2006
     * Version: 0.0 (from parent)
     *
     * Extracted from latest IPORT/STYLER engines.
     *
     * Returns an array of elements with specified ID.
     */
    function ElementsById($id) {
        var c = 0, i = 0, j = 0, k = 0;
        var nodes=[], storage = arguments.callee.storage;
        var elements = document.getElementsByTagName('*');
        var length = elements.length;
        if (storage &&
            storage.nodes &&
            storage.length == length &&
            storage.first == elements[0] &&
            storage.last == elements[length-1]) {
            k = $id;
            while (storage.nodes[k]) {
                nodes[nodes.length] = storage.nodes[k];
                k = $id + '*' + (++i);
            }
        } else {
            storage = { };
            storage.nodes = { };
            storage.length = 0;
            storage.first = elements[0];
            storage.last = elements[length - 1];
            while (length > i) {
                c = elements[i];
                if ((k = c.id) == $id) {
                    nodes[nodes.length] = c;
                    if (storage.nodes[k]) {
                       k = c.id + '*' + (++j);
                    }
                }
                i++;
                storage.nodes[k] = c;
                storage.length++;
            }
            arguments.callee.storage = storage;
        }
        return nodes;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.