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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:10:53+00:00 2026-06-11T09:10:53+00:00

I have a generated HTML menu that looks like this : <ul class=principal-nav> <li><a

  • 0

I have a generated HTML menu that looks like this :

<ul class="principal-nav">
     <li><a href="#">Item 01</a> <span class="posts-amount">(12)</span></li>
     <li><a href="#">Item 02</a> <span class="posts-amount">(7)</span></li>
     <li><a href="#">Item 03</a> <span class="posts-amount">(25)</span></li>
</ul>

And I need it to look like this :

<ul class="principal-nav">
     <li><a href="#">Item 01 <span class="posts-amount">(12)</span></a></li>
     <li><a href="#">Item 02 <span class="posts-amount">(7)</span></a></li>
     <li><a href="#">Item 03 <span class="posts-amount">(25)</span></a></li>
</ul>

I tried to manipulate the DOM but I’m a jQuery beginner and, so far, all I succeed in getting was this result :

<ul class="principal-nav">
     <li><a href="#">Item 01 <span class="posts-amount">(12)</span> <span class="posts-amount">(7)</span> <span class="posts-amount">(25)</span></a></li>
     <li><a href="#">Item 02 <span class="posts-amount">(12)</span> <span class="posts-amount">(7)</span> <span class="posts-amount">(25)</span></a></li>
     <li><a href="#">Item 03 <span class="posts-amount">(12)</span> <span class="posts-amount">(7)</span> <span class="posts-amount">(25)</span></a></li>
</ul>

Here’s my jQuery code :

$('.principal-nav li a').append(
     $('span.posts-amount').clone().end()
);

I think I can get something working using “each” but for some reason, I couldn’t achieve it yet.
I’ve been looking at a whole lot of boards and tutorials, but couldn’t find any answer to my question.

Thank you for helping me out !

  • 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-11T09:10:54+00:00Added an answer on June 11, 2026 at 9:10 am

    Demo: http://jsfiddle.net/RJzq7/

    $('.principal-nav li a').each(function () {
      $(this).next().appendTo(this);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model that looks something like this: public class SampleModel { public
I'm designing a navigation bar. The code looks like this: <nav class=menu> <ul class=topnav>
I have a Servlet called Menu that generates some html and a dynamic menu,
I have docbook generated HTML that contains small, fixed size images. All these images
I have various pieces of generated HTML/JS that I load into Activity with WebView#loadDataWithBaseURL.
I have a simple app with a full screen UIWebView. This contains HTML generated
I have a site Index.html and there is a categories menu generated from database.
I have bought a Joomla template from Template monster. It looks like this template
In my Magento install, I have a dropdown menu that is generated from a
I have some auto-generated HTML code. When I add a float:left; on the shared

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.