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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:02:42+00:00 2026-05-23T11:02:42+00:00

I am a jQuery novice. I enjoy using jQuery and am attempting to get

  • 0

I am a jQuery novice. I enjoy using jQuery and am attempting to get better at it.

I have the following list as a menu:

Page home: no child

<ul class="menu">
<li>Team 1 Photos</li>
<li>Team 2 Photos</li>
<li>Group Activities</li>
</ul>

Sub-page has child

<ul class="menu">
<li>Team 1 Photos</li>
<li>Team 2 Photos</li>
<li>Group Activities
    <ul class="children">
    <li>Team 1 News</li>
    <li>Team 2 News</li>
</ul>
</li>
</ul>

My CSS is:

ul.children {
    width: auto;
    margin-left: 0;
}
ul.children li{
    border-bottom:1px solid #999;
    margin-bottom: 10px;
   padding-bottom: 3px;
}
ul.children li:last-child{
    border-bottom:1px solid #999 !important;
}
ul.menu {
    width: auto;
    margin-left: 0;
}
ul.menu li{
    border-bottom:1px solid #999;
    margin-bottom: 10px;
   padding-bottom: 3px;
}
ul.menu li:last-child{
    border-bottom:none;
}

I am trying to achieve; the last <li> to have border-bottom if there is no child.
the last <li> to have no border if there is a child

I hope I am making sense

I have tried way to either directly apply the border yes/no or add a class so I can apply the style:

jQuery('#menu ul li:has(ul)').parent('li').prev()).css('border','1px solid #000');

if (jQuery('.menu li:has(ul)') ) {
  ('ul.menu li:last-child').add Class('borderme');

jQuery('.menu li:has(ul)').append('borderyes');

An now I am stuck so please steer me in the right direction so I can learn how to achieve this.

Thank you

LRL

  • 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-23T11:02:43+00:00Added an answer on May 23, 2026 at 11:02 am

    You could simplify your css.

    ul.menu, ul.children {
            width: auto;
            margin-left: 0;
        }
    ul.menu li{
            border-bottom:1px solid #999;
            margin-bottom: 10px;
            padding-bottom: 3px;
        }
    

    You don’t need seperate styles for .children because the descendent selector on .menu will take care of all the <li> in your markup. All <li> within .menu will now have a border. To remove border from the last child <li> of .menu if it has a sub-menu, you could use the following code.

    $('ul.menu > li:last-child').has('ul').css('border-bottom','none');
    

    Please note that I have used a child selector in jquery instead of a descendent selector.

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

Sidebar

Related Questions

I'm a jQuery novice, I have the following jQuery written to show a div
I can't seem to get jQuery to notice the div within the following markup
I am a novice learning jQuery and I have a scenario; I have a
Disclaimer: JS novice I have a JS widget that depends on JQuery. The widget's
I'm a crappy novice programmer and have been struggling to get this working for
I am a bonifide jQuery novice and I have some jquery code that I
I follow directions well but am still a novice in jquery. I installed using
I am a jQuery novice and each of the following work fine on their
I currently have this jquery code to set the current class, I am a
I am a novice using jQuery UI datepicker on a commerce site to set

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.