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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:45:46+00:00 2026-05-21T08:45:46+00:00

I have unknown number of divs with increasing ID’s: <div id=source-1 data-grab=someURL/>Content</div> <div id=source-2

  • 0

I have unknown number of divs with increasing ID’s:

<div id="source-1" data-grab="someURL"/>Content</div>
<div id="source-2" data-grab="anotherURL"/>Content</div>
<div id="source-3" data-grab="anddifferentURL"/>Content</div>
<div id="source-4" data-grab="andthelastoneURL"/>Content</div>

And I have another list:

<ul>
   <li id="target-1" class="target"><a href="#"> </a></li>
   <li id="target-2" class="target"><a href="#"> </a></li>
   <li id="target-3" class="target"><a href="#"> </a></li>
   <li id="target-4" class="target"><a href="#"> </a></li>
</ul>

Now, what I want to achive is grabbing data-grab URL from source-1 and append it to target-1 as a image and so forth. So finally the output list will look just like:

<ul>
       <li id="target-1"><a href="#"><img src="someURL" /> </a></li>
       <li id="target-2"><a href="#"><img src="anotherURL" /> </a></li>
       <li id="target-3"><a href="#"><img src="anddifferentURL" /> </a></li>
       <li id="target-4"><a href="#"><img src="andthelastoneURL" /> </a></li>
</ul>

I’m grabbing all the data from the first list, but I’m not sure how to append right source element to right target element?

 $(document).ready(function(){
                $('.target').each(function(){
                var URL = jQuery(this).data('grab');
                });
            });
  • 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-21T08:45:47+00:00Added an answer on May 21, 2026 at 8:45 am
    $(document).ready(function(){
      $('.target').each(function(){
         var $this = $(this);
         var divID = "source-" + ($this.id()).split("-")[1];
         $("a", $this).append('<img src="' + $(divID).data("grab") + '" />');
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for taking the time to read this. I have an unknown number of
I have a groovy script with an unknown number of variables in context at
I have a graph which contains an unknown number of disconnected subgraphs. What's a
I have a repeater control, and I want to put an unknown number of
In C++, I have a map<string, string> , containing an unknown number of entries.
I have numerous functions (unknown at design time) that each take a specific number
I have an array of points in unknown dimensional space, such as: data=numpy.array( [[
Say I have the unknown number of questions. For example: Is the sky blue
I have an array containing an unknown number of items that I would like
This is the problem: I have a table with unknown number of columns. all

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.