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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:16:40+00:00 2026-06-04T17:16:40+00:00

I need to get content from a UL list and then be able to

  • 0

I need to get content from a UL list and then be able to use that to email. But I’m stuck on getting the ul list in jquery. I’ve searched and found the following:

$(document).ready(function(){
    $("#send").click(function() { //When trigger is clicked...
            var optionTexts = [];
            $("#thelist").each(function() { optionTexts.push($(this).text()) });
            var text = '"' + optionTexts.join('"<br/> "') + '"';

            $("#result").append(text);

        });
    });

but this returns all contents inside the page :S
Here’s my ul list:

<ul id="thelist">
  <li style="height: 65px; display: list-item; ">
    <ul>
      <li class="botHeader">
        "Evelin dice"
                <span>14:37:52</span>
      </li>
      <li class="botMsg">
        "Hola, bienvenido"
      </li>
    <ul>
  </li>
  <li style="height: 26px; display: list-item; ">
    <ul>
      <li class="userHeader">
        "Usted dice"
                <span>14:37:59</span>
      </li>
      <li class="userMsg">
        "Hola como estas"
      </li>
    <ul>
  </li>
  <li style="height: 39px; display: list-item; ">
    <ul>
      <li class="botHeader">
        "Evelin dice"
                <span>14:37:59</span>
      </li>
      <li class="botMsg">
        "Gracias por preguntar, todo bien"
      </li>
    <ul>
  </li>
</ul>

<a href="#" id="send">enviar</a>
<div id="result">

</div>
  • 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-04T17:16:42+00:00Added an answer on June 4, 2026 at 5:16 pm

    This should do the whole lot in one go, and without any temporary variables:

    $('#result').append(
        $('#thelist').find('li').filter(function() {
            return $(this).find('ul').length === 0;
        }).map(function(i, e) {
            return $(this).text();
        }).get().join('<br/>')
    );
    

    You have to only consider the <li> elements that don’t have any <ul> descendents.

    Working demo at http://jsfiddle.net/alnitak/JVS7d/

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

Sidebar

Related Questions

I use file_get_contents(http://www.mydomain.com); to get the content. Then I need to search through it
I have one variable whose content I need to get from a remote server,
I need to clear the <div> and insert new content I get from the
I just need to get a list of the most recent changes from CVS
I need a method to get the data from an external editor. def _get_content():
I need to get the contents from this URL http://google.fr/ok in a NSString can
I need to get the content of URL bar (of currently opened tab) of
I need to get the complete content of a column of two tables in
How can I get content of a DIV using regular expression. What I need
I need to get the last string content of the url between / and

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.