2

Is there an easy way to grab the text from this div with out getting any child elements?

<div id="someselector">
   <strong>Title Text Unwanted</strong> This is the text I need
</div> 

I know I probably could do a substring on the strong. I was just wondering if there was a function that could automatically do it for me in jQuery like:

 $('#someselector').html().not('strong').text()
johnny 5
  • 19,893
  • 50
  • 121
  • 195

1 Answers1

5

It basically boils down to this:

$("#someselector").clone().children().remove().end().text();

First, you clone the element, get its children, remove them and then get the text of the clone.

Delirium
  • 66
  • 4