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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:43:50+00:00 2026-05-20T17:43:50+00:00

I have a div with several paragraphs and another div with a set of

  • 0

I have a div with several paragraphs and another div with a set of images. Like so:

<div id="interview">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
<p>Ased do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p>Three ipsum dolor sit amet, consectetur adipisicing elit</p>
<p>Four do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p>Five ipsum dolor sit amet, consectetur adipisicing elit</p>
<p>Six do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>

<div id="images">
<img src="http://placehold.it/100x100/ff0000" class="imgThumb" id="img1" />
<img src="http://placehold.it/100x100/39719c" class="imgThumb" id="img2" />
<img src="http://placehold.it/100x100/eeeeee" class="imgThumb" id="img3" />
<img src="http://placehold.it/100x100/000000" class="imgThumb" id="img4" />
</div>

What I’d like to do is use jQuery to take each one of the images and insert it after every second paragraph. I’m just not well versed enough in jQuery to traverse and loop through the divs to accomplish what I need. 🙁

  • 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-20T17:43:51+00:00Added an answer on May 20, 2026 at 5:43 pm

    By “every second paragraph,” I assume you mean the odd-numbered paragraphs (zero-indexed), e.g., 1, 3, 5, … . I assume this because you have 4 images and 6 paragraphs. If I assume wrong, then you’d change the :odd selector to something like :nth-child(3n+1), which would select paragraphs 1, 4, 7, …

    $(function ()
    {
        var $images = $('#images > img');
    
        $('#interview > p:odd').each(function (i)
        {
            $(this).after($images.get(i));
        });
    });
    

    API docs:

    • :odd selector
    • .after()

    Oh also

    check out the demo →

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

Sidebar

Related Questions

I have several Div's that appear and would like each one to have a
If you have several div s on a page, you can use CSS to
I have an absolutely positioned div containing several children, one of which is a
Imagine that you have several links on a page. When you clicked, a div
I have several Div tags on a page which are dynamic, i.e. depending on
I have a div containing several other divs containing an image. It looks smth
I have div containing a list of flash objects. The list is long so
I have a div and an iframe on the page the div has z-index:
I have a div in which a page is loaded with the DojoX Layout
I have a div with overflow:hidden , inside which I show a phone number

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.