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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:10:55+00:00 2026-06-09T21:10:55+00:00

so i have a dynamically generated set of links: <a class=linkhref=linkto/1 id=1>link 1</a> <a

  • 0

so i have a dynamically generated set of links:

<a class="link"href="linkto/1" id="1">link 1</a>
<a class="link"href="linkto/2" id="2">link 2</a>
<a class="link"href="linkto/3" id="3">link 3</a>

and then these links calls an action that returns a list of data and populates a div (which is also dynamically generated right under the link)

<a class="link" href="linkto/1" id="1">link 1</a>
<div class="container" id="1"></div>
<a class="link" href="linkto/2" id="2">link 2</a>
<div class="container" id="2"></div>
<a class="link" href="linkto/3" id="3">link 3</a>
<div class="container" id="3"></div>

this is my jquery

var url;
        var id;
        $('a.link').click(function () {
            url= $(this).attr('href');
            id = $(this).attr('id');
            $.ajax({
                url: url,
                dataType: 'JSON',
                success: function (data) {
                    var list = '';
                    var listcontainer = $('div.container').attr({ id: id.toString() });
                    $.each(data, function (i, client) {
                        list += '<div class="' + client.Id + '">Name of client = ' + client.Name + '</div>';
                    });
                    $(listcontainer).addClass("box-list-small");
                    $(listcontainer).html(list);
                },
                error: function (data) {
                    console.log('Cant load client list.');
                }
            });
            return false;
        });

so what I’m trying to achieve is that there would be a link and when it gets clicked a box under it opens up to show the list. the problem is, everytime i click the link of one, it populates ever “container” in the page. Does that make sense?

Appreciate the time!

Thanks!!

EDIT: modified pseudo code.

<div class="row">
    <a class="link" href="linkto/1" id="1">link 1</a>
    <a class="someotherlink">someotherlink</a>
  </div>
 <div class="row">
    <div class="container" id="1"></div>
</div>
<div class="row">
    <a class="link" href="linkto/2" id="2">link 2</a>
    <a class="someotherlink">someotherlink</a>
</div>
<div class="row">
    <div class="container" id="2"></div>
</div>
<div class="row">
    <a class="link" href="linkto/3" id="3">link 3</a>
    <a class="someotherlink">someotherlink</a>
</div>
<div class="row">
    <div class="container" id="3"></div>
</div>
  • 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-09T21:10:56+00:00Added an answer on June 9, 2026 at 9:10 pm

    The line: var listcontainer = $('div.container').attr({ id: id.toString() });
    queries the DOM for every div with class “container”, then sets all of their ids to the clicked link’s id.. and returns the collection of divs into listcontainer variable. Then you call .html(list) on it so it sets all the containers.

    You probably want something more like this:

    $('a.link').click(function () {
            var el = $(this),
                url= el.attr('href'),
                id = el.attr('id');
            $.ajax({
                url: url,
                dataType: 'JSON',
                success: function (data) {
                    var list = '';
                    $.each(data, function (i, client) {
                        list += '<div class="' + client.Id + '">Name of client = ' + client.Name + '</div>';
                    });
                    el.next('.container').addClass("box-list-small").html(list);
                },
                error: function (data) {
                    console.log('Cant load client list.');
                }
            });
            return false;
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a set of radio buttons that are dynamically generated (via JSON call):
I have a dynamically generated rss feed that is about 150M in size (don't
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
I have a series of dynamically generated inputs that I need to have ajax
I have a trivia page that is dynamically generated by some javascript code. It
I have content that is being dynamically generated. How to I listen to a
I have a select box that gets generated dynamically. I want to allow users
I have an InstallScript installer that utilizes dynamic file links for several components. These
I have the following variable being dynamically set by user generated content: $variable =
I have a list like the following: <ul id=links> <li><a href=/example-url-1>Link 1</a></li> <li><a href=/example-url-2>Link

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.