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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:57:50+00:00 2026-06-04T11:57:50+00:00

I have a textarea which contains some HTML (don’t ask me why! :)) The

  • 0

I have a textarea which contains some HTML (don’t ask me why! :))

The HTML looks something like:

<div class="text-tag">some gibberish 1</div> 
<div class="text-tag">some gibberish 2</div> 
<div class="text-tag">some gibberish 3</div>

How do I get values from it namely: some gibberish 1, some gibberish 2 and some gibberish 3?

Edit:

My HTML look like this:

<textarea>
    <div class="text-tag">some gibberish 1</div> <div class="text-tag">some gibberish 2</div>  <div class="text-tag">some gibberish 3</div>
</textarea>

This html is typed by the user and I need to parse the HTML this is typed by user in textarea.

  • 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-04T11:57:52+00:00Added an answer on June 4, 2026 at 11:57 am
    var alltext = [];
    
    $('div.text-tag').each(function() {
      alltext.push($(this).text());
    });
    
    console.log(alltext.join(', ')); // output: some gibberish 1, some gibberish 2, some gibberish 3
    

    or

    ​var alltext = $('div.text-tag').text();
    console.log(alltext); // output: some gibberish 1some gibberish 2some gibberish 3
    

    or

    var alltext = [];
    $('div.text-tag').text(function(index, text) {
       alltext.push(text);
    });
    console.log(alltext.join(', '))​​; // output: some gibberish 1, some gibberish 2, some gibberish 3
    

    According to your edit:

    var content = $($.trim($('textarea').val())),
        alltext = [];
    $(content).each(function() {
      if(this.nodeType != 3)
          alltext.push($(this).text());
    });
    console.log(alltext.join(', '));
    

    Sample workout 1

    ​
    Another sample:

    var textarea = $("textarea").val(),
        alltext = [];
    $(textarea).filter(function(index, item) {
       if($(item).hasClass('text-tag'))
           alltext.push($(item).text());
    })
    console.log(alltext.join(', '));
    

    Sample workout 2

    ​

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

Sidebar

Related Questions

I have a textarea which is a tinymce editor. This text area contains html.
I have a product management page that contains a textarea in which some html
I would like to have some functionality by which if I write <textarea maxlength=50></textarea>
I have an HTML form which contains a drop down, a tinyMCE textarea, and
I have a textarea which already contains some content (haml code below) //haml code
I have a textarea within an HTML page into which my users paste content.
I have a text area on which I would like to listen to change
I have a div which contains 2 child elements. The 1st div have content
I have a textarea form which takes a large block of text. In this
I have a php multidimensional array which looks like this: $fields = array( array('input',

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.