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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:04:03+00:00 2026-06-03T09:04:03+00:00

<div class=newstitle> <ul class=newstitle> @foreach (var item in Model.Content) { if (item.Value != null)

  • 0
       <div class="newstitle">
            <ul class="newstitle">
                @foreach (var item in Model.Content)
                {
                    if (item.Value != null)
                    { 
                     <li>
                            <div class="newstitle_title">@item.Key.Name</div>
                        </li>
                    }
                }
           </ul> 
  </div>

 <script type="text/javascript">
  $(document).ready(function () {
     $('.newstitle li:nth-child(odd)').addClass('last');
 });
 </script>

I have this code, i ve been trying to run and it s breaking the css.
Broken CSS

However, it should be like the following, please see the spacing between images:
enter image description here

how can i fix this? if you see there is both div and ul has the same class name.

This is what the generated html should be:

<div class="newstitle">
    <ul class="newstitle">
        <li>image</li>
        <li>image</li>
        <li>image</li>
        <li class="last">image</li>
        <li>image</li>
        <li>image</li>
        <li>image</li>
        <li class="last">image</li>
        <li>image</li>
        <li>image</li>
        <li>image</li>
        <li class="last">image</li>
    </ul>
    </div>

and here is the css:

.newstitle  {width:600px;overflow:hidden;margin:15px auto;}
.newstitle li {float:left;width:140px;height:170px;overflow:hidden;margin:0px 13px 0px 0px;display:inline;position:relative;}
.newstitle .last {float:left;width:140px;height:170px;overflow:hidden;margin:0px 0px 0px 0px;display:inline;position:relative;}
  • 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-03T09:04:05+00:00Added an answer on June 3, 2026 at 9:04 am

    Try this :

    $('li', 'ul.newstitle').filter(function() {return $(this).index()%4===0}).addClass('last');
    

    FIDDLE

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

Sidebar

Related Questions

I have this code: <div class = content-dir-item> <p>Text input</p> <img src=./images/email.png class =
%div{:class => [@item.type, @item == @sortcol && [:sort, @sortdir]] } Contents could render as
<div class = 'buttons'> <button type=submit class=regular name=save> <img src=elephant.png alt=/> Memory </button> </div>
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());
My div with class name 'header-body-right' doesn't seem to be floating to the left
I can select the first item in the div using $('.class:first') Now since I
I have some class like this <div class = student> <div class = name>Adam
How can I change a div class name when clicking on it? Eg: <div
How to take content from a div class one by one and then load
I have div tag with css class name. div class name is same in

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.