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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:20:51+00:00 2026-05-15T10:20:51+00:00

I’m working on the comments section of a WP theme, and the styling requires

  • 0

I’m working on the comments section of a WP theme, and the styling requires the use of some clever jQuery in order to make it work right… However, when trying to style admin comments in a long nested UL, I’m having trouble traversing the DOM with jQuery to find the elements I need to adjust the CSS for…

Here’s what I’ve tried using:

$('.commentlist li.admin').each(function() {
  if ($(this).parents('li').size() > 0 ) {
    //Has parent LI, so this is a child comment
    $(this).children('.avatar').css({'background-position':'right -2530px'});
    $(this).children('.avatar img').css({'border-right':'1px solid #fff','border-bottom':'1px solid #fff'});
  }
  else {
    //Has no parent LI, top level comment
    $(this).children('.avatar').css({'background-position':'0 -2530px'});
    $(this).children('.avatar img').css({'border-right':'1px solid #fff','border-bottom':'1px solid #fff'});
  }
});

Basically I want to apply certain styles to elements within “top level” LI elements with the class “admin”, and apply another set of styles to elements within “nested” LI elements with the class “admin”.

I thought that by checking to see if an LI element had a parent LI then that would be a quick way to do it, but I’m apparently going about it the wrong way…

Any ideas?

PS- Here’s a sample of my HTML structure:

            <ul class="commentlist">
            <li>
                <div class="border-fake">
                    <div class="comment-header">
                        <small>3rd may, 2009</small>
                        <div class="rank rank2"></div>
                    </div><!--/comment-header-->
                    <div class="comment-body">
                        <div class="avatar">
                            <img src="http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=61" />
                        </div><!--/avatar-->
                        <h4 class="comment-author">Joe Bloggs</h4>
                        <small class="author-url">ohmygodisuck.me</small>
                        <div class="clearit"></div>
                        <div class="comment-text">
                            <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                            <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                        </div><!--/comment-text-->
                        <div class="reply">
                            <a href="#">reply</a>
                        </div><!--/reply-->
                    </div><!--/comment-body-->
                </div><!--/border-fake-->
            </li>
            <li class="admin">
                <div class="border-fake">
                    <div class="comment-header">
                        <small>3rd may, 2009</small>
                        <div class="rank rankadmin"></div>
                    </div><!--/comment-header-->
                    <div class="comment-body">
                        <div class="avatar">
                            <img src="http://www.gravatar.com/avatar/e610fd44bdd000891b3a67a22d1676b7?s=61" />
                        </div><!--/avatar-->
                        <h4 class="comment-author">Jamie Carter</h4>
                        <small class="author-url">jamiecarter.me</small>
                        <div class="clearit"></div>
                        <div class="comment-text">
                            <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                            <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                        </div><!--/comment-text-->
                        <div class="reply">
                            <a href="#">reply</a>
                        </div><!--/reply-->
                    </div><!--/comment-body-->
                </div><!--/border-fake-->
                <ul class="children">
                    <li>
                        <div class="border-fake">
                            <div class="comment-header">
                                <small>3rd may, 2009</small>
                                <div class="rank rank4"></div>
                            </div><!--/comment-header-->
                            <div class="comment-body">
                                <div class="avatar">
                                    <img src="http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=44" />
                                </div><!--/avatar-->
                                <div class="comment-text">
                                    <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet. Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                                    <p>Amet! Ut aliquam tempor sit tempor. Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet. Dignissim vel! Amet.</p>
                                    <div class="clearit"></div>
                                    <h4 class="comment-author">Weird Guy</h4>
                                    <small class="author-url">howdydoo.com</small>
                                </div><!--/comment-text-->
                                <div class="reply">
                                    <a href="#">reply</a>
                                </div><!--/reply-->
                            </div><!--/comment-body-->
                        </div><!--/border-fake-->
                    </li>
                    <li>
                        <div class="border-fake">
                            <div class="comment-header">
                                <small>3rd may, 2009</small>
                                <div class="rank rank1"></div>
                            </div><!--/comment-header-->
                            <div class="comment-body">
                                <div class="avatar">
                                    <img src="http://www.gravatar.com/avatar/3b3be63a4c2a439b013787725dfce802?s=44" />
                                </div><!--/avatar-->
                                <div class="comment-text">
                                    <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                                    <p>Amet! Ut aliquam tempor sit tempor. In, placerat, mattis mid porta pid? Vut ut tincidunt ac, porta placerat nisi auctor elit? Dignissim vel! Amet.</p>
                                    <div class="clearit"></div>
                                    <h4 class="comment-author">Jimbo Wilson</h4>
                                    <small class="author-url">countrybumpkin.com</small>
                                </div><!--/comment-text-->
                                <div class="reply">
                                    <a href="#">reply</a>
                                </div><!--/reply-->
                            </div><!--/comment-body-->
                        </div><!--/border-fake-->
                    </li>
                </ul>
            </li>
        </ul>

And just for good measure, here’s an online demo so you can see what’s going on and what’s not… http://joshjones.me/comment-test/

  • 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-15T10:20:52+00:00Added an answer on May 15, 2026 at 10:20 am

    Unless I’m mistaken, the nested ones are all under the .children class, right?

    So why not something like this:

    ul.commentlist > li.admin > .border-fake > .comment-body > .avatar {
        background-position: right -2530px;
    }
    ul.commentlist > li.admin > .border-fake > .comment-body > .avatar > img {
        border-right:1px solid #fff;
        border-bottom:1px solid #fff;
    }
    
    ul.children .avatar {
        background-position:0 -2530px;
    }
    ul.children .avatar > img {
        border-right:1px solid #fff;
        border-bottom:1px solid #fff;
    }
    

    EDIT:

    It would seem as though your 4 unique selector pairs would be:

        <!-- Top level non-admin -->
    ul.commentlist > li > .border-fake > .comment-body > .avatar
    ul.commentlist > li > .border-fake > .comment-body > .avatar > img
    
        <!-- Top level admin ( should override non-admin ) -->
    ul.commentlist > li.admin > .border-fake > .comment-body > .avatar
    ul.commentlist > li.admin > .border-fake > .comment-body > .avatar > img
    
        <!-- Nested level non-admin -->
    ul.children > li > .border-fake > .comment-body > .avatar
    ul.children > li > .border-fake > .comment-body > .avatar > img
    
        <!-- Nested level admin ( should override non-admin ) -->
    ul.children > li.admin > .border-fake > .comment-body > .avatar
    ul.children > li.admin > .border-fake > .comment-body > .avatar > img
    

    The ones with the .admin class should override the ones without.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.