So I have this piece of jQuery inside one of my methods:
videos: $('iframe[src*="vimeo"], iframe[src*="youtube"]'),
What it currently does is select all <iframe> elements with the src containing youtube.
Here is what I'm attempting to do:
Select all the <iframe> elements with the src containing youtube and NOT containing the modal class in the parent element.
So let's say that I have this:

If it has the modal class inside the <section> don't select the <iframe>.
Although I think jQuery has a specific way to do this, you can also use the CSS , not the pseudo-class .
const iframes = $('section:not(.modal) iframe[src*="vimeo"], section:not(.modal) iframe[src*="youtube"]'); Note that this will work if some parent/ancestor section doesn't have the modal class.
If you need it to be the direct parent, use:
const iframes = $('*:not(.modal) > iframe[src*="vimeo"], *:not(.modal) > iframe[src*="youtube"]'); I've also used the universal selector * so it's not specific to the section element.