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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:24:32+00:00 2026-06-04T11:24:32+00:00

I need to add a div tag after each 5 images, so the html

  • 0

I need to add a div tag after each 5 images, so the html markup should be something like this:

<div>
      <img src="http://farm1.static.flickr.com/143/321464099_a7cfcb95cf_t.jpg" />
      <img src="http://farm4.static.flickr.com/3089/2796719087_c3ee89a730_t.jpg" />
      <img src="http://farm1.static.flickr.com/79/244441862_08ec9b6b49_t.jpg" />
      <img src="http://farm1.static.flickr.com/28/66523124_b468cf4978_t.jpg" />

</div>
<div>

      <img src="http://farm1.static.flickr.com/163/399223609_db47d35b7c_t.jpg" />
      <img src="http://farm1.static.flickr.com/135/321464104_c010dbf34c_t.jpg" />
      <img src="http://farm1.static.flickr.com/40/117346184_9760f3aabc_t.jpg" />
      <img src="http://farm1.static.flickr.com/153/399232237_6928a527c1_t.jpg" />
    </div>
<div>

      <img src="http://farm4.static.flickr.com/3629/3323896446_3b87a8bf75_t.jpg" />
      <img src="http://farm4.static.flickr.com/3023/3323897466_e61624f6de_t.jpg" />
      <img src="http://farm4.static.flickr.com/3650/3323058611_d35c894fab_t.jpg" />
      <img src="http://farm4.static.flickr.com/3635/3323893254_3183671257_t.jpg" />
    </div>

I have to use foreach loop thats the requirement , apart from that i can use any control statement , can any one provide any assistance with this logic, i have tried something like this with no succes , the maximum images are 100 , thats why i initialise an int to 100

 foreach (var page in images)
 {
    int b = 100 ;
    for (int a = 0 ; a = b ; a++)
    {
        <div><img src="page.name" alt="page.alt" /> </div>
    }
 }
  • 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-04T11:24:35+00:00Added an answer on June 4, 2026 at 11:24 am

    something along these lines should get you going in the right direction

    foreach (var page in images)
     {
        int b = 100 ;
        bool first=true;
        bool wroteDivEnd = false;
        for (int a = 0 ; a = b ; a++)
        {
            wroteDivEnd=false;
            if (a% 4==0)
            {
               if (!first)
               { 
                  // as long as this is not the first time we have written a 
                  //start div, then we need to write and end one
                  //write previous div end </div>
                  wroteDivEnd=true;
               }
               //write new div start <div>
               //set the flag so we know we have written the first start div
               first=false;
            }
            // write out the images
            <img src="page.name" alt="page.alt" /> 
    
        }
        //make sure your last </div> is written
        if(!wroteDivEnd)
        { 
         //write out the final missing </div>
        }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add some html right after the body tag so like :
i need to add some text DIV's on each slide of a Nivoslider. I
How do I add a div after each item in a checkbox list. My
Let's say you have the following HTML: <html> <div style=text-align: center;> <img src=http://www.ps.uci.edu/~tomba/ants/sugar.jpg width=50
This seems like it should be something easy, yet it is driving me mad!!
$(function () { var ptitle = $('div.portfolioItem div.image img').attr(title); $(this).each(function () { $('a.play').attr({ 'title':
Need: Find a way to add a valid tag/attribute/property to a normal html control.
I need to add a class to a div based on how cookies are
I need to add css height to each page dynamically with jQuery. So far
I need to add a dependency on a specific version of GDIPlus. This is

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.