Currently, my jquery code is selecting a section of copy:
str = '.main-content p:nth-child('+num+')';
string = jQuery(str).html();
(num is declared elsewhere and is not an issue).
While this successfully selects all content within the p tag, the problem arises when the p tags I'm selecting have nested a tags and strong tags. Is there a way to select the p tag excluding specific elements like the strong tag? I attempted the following code:
str = '.main-content p:nth-child('+num+') :not(strong)';
Unfortunately, this selects all child elements except for strong, but it does not retrieve the actual content inside the p tag.
If you have any suggestions or ideas, please feel free to share!
Thank you in advance!
Edit - Example requested:
<p><strong>Content that I want to ignore</strong> This is some content which I would like to include. <a href="#">also keep this</a></p>
Desired output:
<p>This is some content which I would like to include. <a href="#">also keep this</a></p>
or this:
This is some content which I would like to include. <a href="#">also keep this</a>