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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:58:24+00:00 2026-05-31T10:58:24+00:00

I have a variable name of which gives me few elements: console.log(name) = joe,foo,john,maria

  • 0

I have a variable name of which gives me few elements:

console.log(name) = joe,foo,john,maria

and the variable src gives me a link of each of the names:

console.log(src) = www.joe.com, www.foo.com, www.john.com and www.maria.com respectively.

Now I want to append a div of which each will have the id of the ‘name’ and for text the link for each so I will end up with something likes this:

<div id="joe">www.joe.com</div>
<div id="foo">www.foo.com</div>
<div id="john">www.john.com</div>
<div id="maria">www.maria.com</div>

This is what I have so far:

var arr = [];
var textToInsert = '';
$.each(arr, function(count, item) {
  textToInsert  += '<div id="'+ name +'">' + a + '</div>';
});

$('body').append(textToInsert);
  • 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-31T10:58:25+00:00Added an answer on May 31, 2026 at 10:58 am

    Assuming name and src are arrays of strings, you’re just about there–get the index of the name item from name and use it to grab the corresponding src url in the other array. Otherwise, make a map out of the two lists and do it that way.

    var arr = ['a', 'b', 'c', 'd'];
    var arr2 = [ 1, 2, 3, 4];
    var result = "";
    
    $.each(arr, function(index, value) {
        result += '<div id="' + value + '">' + arr2[index] + "</div>"
    
    });
    
    $('body').html(result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a url. **/deals/image/+name** name is a variable which gives the image name.
I have a variable which has the directory path, along with the file name.
I have Man class which also has 2 variable : description and name. At
I have a class Topic and Group which both have a variable called 'name',
I have this ingredients array which contains multiple variables (like name, icon, value etc.).
I have a variable name subject. For each unique subject there are 240 response
I have just discovered a variable name that is misspelled. If it were hidden
I have a string containing the variable name. I want to get the value
I have the following PowerShell loop: Set-Variable -Name YELLOW -Option ReadOnly -Value 0 Set-Variable
Using for loop in PHP can we have numbers associate with a variable name?

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.