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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T11:37:43+00:00 2026-06-05T11:37:43+00:00

I want to append <li> in <ul> using jQuery. I’ve done it successfully with

  • 0

I want to append <li> in <ul> using jQuery. I’ve done it successfully with the following line:

var ChosedItem = $("#chosedItem");
ChosedItem.append('<li id=' + $(this).attr('id') + ' limit=' + $(this).attr('limit') + ' ><span>' + $(this).children(0) + '</span></li>');

in this, #chosedItem is the div id where the <ul> exists

But the problem in my case is if my <li> items contain spaces then it is not added after [0]th position of children because I am using chlidren(0). What can I use in place of children(0) to add <li> items that contain multiple spaces?

  • 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-05T11:37:45+00:00Added an answer on June 5, 2026 at 11:37 am

    Try this

    $('#chosedItem').children().filter(function(){    
    
      if($(this).text().split(' ').length > 2) //Elements with two or more space will be returned
         return $(this);
    
    }).append('<li id=' + $(this).attr('id') + ' limit=' + $(this).attr('limit') + ' ><span>' + $(this).children(0) + '</span></li>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to conditionally add an attribute using jQuery: var $this = this .append(...)
I want to append using jquery some <input> fields to a form like this
All. I am using jquery. And I want to append element into loaded html
I have the following HTML: <div id=dynamicRadioButtons> </div> Using jQuery I'd like to append
I want to hide select itself using jquery if there is no option append
I want to use jquery append() using an id as my selector, however the
I want to append a <br /> to a particular class. Using the :after
Basically I want to append <span></span> inside the anchor tag but outside of home.
I want to append a div tag generated by jQuery dynamically with a javascript
I want to load a xml file using Jquery . The xml is generated

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.