right now, I have this code:
var source = $('p').filter(function(){
return $(this).text().length > 300;})
.parent().slice(0,1);
By filtering through p elements, I find the first one that is longer than 300 characters, and store the parent of that in source. My question is …how would I only get text content (typeNode 3). I know this might be a stupid question but trying this.typeNode == 3 doesn’t seem to work
The answer below seems to work in some cases, for more clarity, Im putting a border around all the “p” children of the “source”. Sometimes, the “p” element contains an image and no text. I tried using the answer below for that and it doesn’t seem to work.
filterwill only get element nodes. To get all nodes including text nodes, callcontents(). And switch the words in typeNode tonodeType🙂