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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:08:38+00:00 2026-05-14T17:08:38+00:00

I am trying to create an array with different hrefs to then attach to

  • 0

I am trying to create an array with different hrefs to then attach to 5 separate elements.

This is my code:

var link = new Array('link1', 'link2', 'link3', 'link4', 'link5');

                    $(document.createElement("li"))
                    .attr('class',options.numericId + (i+1))
                    .html('<a rel='+ i +' href=\"page.php# + 'link'\">'+ '</a>')
                    .appendTo($("."+ options.numericId))

As you can see I am trying to append these items from the array to the end of my page so each link will take the user to a different section of the page. But i have not been able to do this. Is there a way to to create elements with different links?

I am new to javascript so I am sorry if this doesn’t make a whole lot of sense. If anyone is confused by what i am asking here I can try to clarify if I get some feedback.

The code I would Like output is:

    <ul class="controls">
    <li class="controls1"><a href="page.php#link1"></a></li>
    <li class="controls2"><a href="page.php#link2"></a></li>
    <li class="controls3"><a href="page.php#link3"></a></li>
    <li class="controls4"><a href="page.php#link4"></a></li>
    <li class="controls5"><a href="page.php#link5"></a></li>
    </ul>

Which is similar to what I am getting, however when I apply the fix that andres descalzo has supplied, my list elements are each repeating themselves 5 times.

Any solutions would be greatly appreciated.

Thanks,

jason

  • 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-14T17:08:39+00:00Added an answer on May 14, 2026 at 5:08 pm

    something like this?:

    *Edit II * for comment

    var link = ['strategy', 'branding', 'marketing', 'media', 'management'],
              refNumericId = $("."+ numericId);
    
      $(link).each(function(i, el){
    
          $("<li></li>")
                .attr("id", numericId + "_" + (i+1))
                .attr("class", numericId + (i+1))
                .html("<a href=\"capabilities.php#"+el+"\"></a>")
                .appendTo(refNumericId);
    
      });
    

    I saw your code in the file ‘easySlider1.7.js’ and you’re including in ‘for’ of the line 123 the code ‘var link = [‘ strategy,”which should go after this ‘for’

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

Sidebar

Ask A Question

Stats

  • Questions 406k
  • Answers 406k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can give you two suggestions. First of all, UDP… May 15, 2026 at 6:16 am
  • Editorial Team
    Editorial Team added an answer To keep the event from firing, here are two options… May 15, 2026 at 6:16 am
  • Editorial Team
    Editorial Team added an answer It seems like you have a memory leak. 6 threads… May 15, 2026 at 6:16 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.