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;

```