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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:54:11+00:00 2026-06-17T14:54:11+00:00

I am using lists in my sidebar, and I want to display a label

  • 0

I am using lists in my sidebar, and I want to display a label number of how many items are in that list.

I have created a JSFiddle here http://jsfiddle.net/WRVgW/ to demonstrate the list and what I am trying to achieve. I am sure this is achievable with Jquery but I am not sure how and looking for some guidance.

In my example I have hardcoded in the number 34 where I want the number to be dynamically generated based on the list below it.

My HTML Code which I commented is pasted below but maybe easier to see it in context with the result in the http://jsfiddle.net/WRVgW/

<div id="sidebar">
<ul class="sidebarSections">
    <li class="submenu">
    <a href="#"><span>Design Projects</span><!--This is the name of the project-->
    <span class="label">34</span></a><!--This is the number which I want to display the number of li items below dynamically (should be 3)-->
        <ul>
            <li><a>Project x</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
        </ul>
    </li>

    <li class="submenu">
    <a href="#"><span>Tech Projects</span><!--This is the name of the project-->
    <span class="label">34</span></a><!--This is the number which I want to display the number of li items below dynamically (should be 5)-->
        <ul>
            <li><a>Project x</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
        </ul>
    </li>

    <li class="submenu">
    <a href="#"><span>IA Projects</span><!--This is the name of the project-->
    <span class="label">34</span></a><!--This is the number which I want to display the number of li items below dynamically (should be 7)-->
        <ul>
            <li><a>Project x</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
            <li><a>Project y</a></li>
            <li><a>Project z</a></li>
        </ul>
    </li>
</ul>

  • 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-17T14:54:12+00:00Added an answer on June 17, 2026 at 2:54 pm

    One possible solution:

    $(".submenu .label").text(function() {
      return $(this).closest(".submenu").find("li").length;
    });
    

    DEMO: http://jsfiddle.net/WRVgW/1/

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

Sidebar

Related Questions

Using the lists webservice I retrieve the items from a list. In the XML
I have two pairs of drag/drop/sortable lists using JqueryUI.http://jqueryui.com/demos/sortable/ My problem is that I
In my application I have a sidebar (on every page) that displays a list
So I have an unordered list with some list-items. I want to show and
I have an unordered list that is being loaded from an external file using
Having created dropdown lists using ViewBag which is working in an edit form. How
I want to get all distribution lists & the members of those lists using
I'm fairly new to C++ standard library and have been using standard library lists
Unowned one-to-many and many-to-many relationships are defined using Sets or Lists of Keys. Let's
I have a page with template No Sidebars I want to list 5 posts'

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.