Add a class to an element when it's loaded
To select the p elements that have an img as child element,
you can use the p:has(&gt; img) selector, like this:

$(".entry-content p:has(&gt; img)").addClass("no-orphans-ctnr");