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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:51:26+00:00 2026-05-28T16:51:26+00:00

From below HTML code I want to get all the text except that in

  • 0

From below HTML code I want to get all the text except that in ‘text_exposed_hide’ span elements.

Initially I tried to get the text from span with no class names.
But this method misses the text which is not within any span but just in div.

How can I get the required text. I need this code in pure javascript

<div id="id_4f1664f84649d2c59795040" class="text_exposed_root">
9jfasiklfsa
  <span>CT:PFOUXHAOfuAI07mvPC/</span>
  <span>NAg==$1ZUlmHC15dwJX8JNEzKxNDGGT</span>
  dwL/L1ubjTndn89JL+M6z
  <span class="text_exposed_hide">...</span>
  <span class="text_exposed_show">
    <span>MDmclkBPI/</span>
    <span>s4B7R9hJyU9bE7zT10xkJ8vxIpo0quQ</span>
    55
  </span>
  <span class="text_exposed_hide">
    <span class="text_exposed_link">
      <a onclick="CSS.addClass($("id_4f1664f84649d2c59795040"), "text_exposed");">See More</a>
    </span>
  </span>
</div

Edit :

I tried removing nodes with class name ‘text_exposed_hidden’ and then getting text from remaining nodes. Below is the code. But its not working
Control is not entering for loop. Even visibleDiv.removeChild(textExposedHideNodes[0]) is not working. I am running this in Chrome Browser 16.0

    //msg is the parent node for the div
    visibleDiv = msg.getElementsByClassName("text_exposed_root");

    textExposedHideNodes = visibleDiv.getElementsByClassName("text_exposed_hide");
    for(var n = 0;n < textExposedHideNodes.legth ; n++ ) { 
        console.log("Removing");
        msg.removeChild(textExposedHideNodes[n]);
    }

    return visibleDiv.innerText;
  • 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-05-28T16:51:27+00:00Added an answer on May 28, 2026 at 4:51 pm

    This code will collect all text from text nodes who don’t have a parent with the class="text_exposed_hide" and put the results in an array.

    It does this non-destructively without removing anything:

    function getTextFromChildren(parent, skipClass, results) {
        var children = parent.childNodes, item;
        var re = new RegExp("\\b" + skipClass + "\\b");
        for (var i = 0, len = children.length; i < len; i++) {
            item = children[i];
            // if text node, collect its text
            if (item.nodeType == 3) {
                results.push(item.nodeValue);
            } else if (!item.className || !item.className.match(re)) {
                // if it doesn't have a className or it doesn't match
                // what we're skipping, then recurse on it to collect from it's children
                getTextFromChildren(item, skipClass, results);
            }
        }
    }
    
    var visibleDiv = document.getElementsByClassName("text_exposed_root");
    var text = [];
    getTextFromChildren(visibleDiv[0], "text_exposed_hide", text);
    alert(text);
    

    If you want all the text in one string, you can concatenate it together with:

    text = text.join("");
    

    You can see it work here: http://jsfiddle.net/jfriend00/VynKJ/

    Here’s how it works:

    1. Create an array to put the results in
    2. Find the root that we’re going to start with
    3. Call getTextFromChildren() on that root
    4. Get the children objects of that root
    5. Loop through the children
    6. If we find a text node, collect its text into the results array
    7. If we find an element node that either doesn’t have a className or who’s className doesn’t match the one we’re ignoring, then call getTextFromChildren() recursively with that element as the new root to gather all text from within that element
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get form parameters from a GET request. The html code
I want to make an application that will grab the HTML from a website
From below array i want the value of _sql to be displayed or we
Using the code below (from a console app I've cobbled together), I add seven
I tried to install MVC Framework from the below URL http://www.asp.net/mVC/ First it is
How can I get only unique departments from the below example? Dept Id Created
To dynamically fill DropDown controls on my HTML Form, I have written code that
Below I have some code which basically animates a div from the bottom of
I have some code that downloads a file from the internet located here: http://www.amsat.org/amsat/ftp/keps/current/nasa.all
I'm working with PHP here. I want to extract the text below a specific

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.