I need to get the text from a div with an id of mycenter, but I do not want the header text i.e.
<h2>This is my Title</h2>. I only want the text after the header. Additionally, sometimes the div does not contain any header.
I tried:
var pageText = $('#mycenter').text();
This correctly returns the text in the div, but this includes "This is My Title".
Any clue on how I can do this?
Thanks
One solution can be
var pageClone = $('#mycenter').clone();
pageClone.find(':header').remove();
var pageText = pageClone.text();
pageClone.remove();
This very well may be inefficient but it will likely serve your needs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With