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

  • Home
  • SEARCH
  • 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 8704037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:59:50+00:00 2026-06-13T02:59:50+00:00

I need to create the following code from the js side, because I am

  • 0

I need to create the following code from the js side, because I am not sure how many of the list items to be printed and i need to set the data-ids from backend… But basically the output needs to look like this;

<ul id="myList">
<li><a data-id="Prev" href="#">Prev</a></li>
<li><a data-id="1" href="#">1</a></li>
<li><a data-id="2" href="#">2</a></li>
<li><a data-id="3" href="#">3</a></li>
<li><a data-id="4" href="#">4</a></li>
<li><a data-id="Next" href="#">Next</a></li>
 </ul>  
  • 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-13T02:59:51+00:00Added an answer on June 13, 2026 at 2:59 am

    Try this code

    // Lets say you get this array from ypur backend..
    
    var arr= ['Prev' , '1','2','3','4','Next'];
    
    var html = '<ul id="myList">';
    
    for(var i =0;i<arr.length ; i++){
        html +=  '<li><a data-id="' + arr[i] + '" href="#">'+arr[i] + '</a></li>' ; 
    }
    
    html += '</ul>';
    
    // Append to your div
    
    $('#list').append(html);
    

    CHECK FIDDLE

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

Sidebar

Related Questions

I have the following code. I need to create list separators before A elements,
Need to convert the following code from Ruby to C#. However I'm kind of
I need to create the following layout: +--------+----------------------------------+-----------+ | fixed | variable | variable
I have the following three arrays and need to create a new two-dimensional array
I need to create relationships for my entities, whereby I have the following scenario:
I need to develop an android app that achieves the following: Create an activity
Hi I have the following interfaces that I need to create. Can you just
Following my previous question , I need to create a value consisting of a
In MySQL, I need to create a new table called users with the following
Oh great Stackoverflow, I beseech thee... I need to do the following: CREATE UNIQUE

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.