Suppose this code:
<pre>
<div class="wp-caption"></div>
<p> </p>
</pre>
I would like to check if after a <div> with class wp-caption there is a <p> with nbsp;. If there is, remove it.
My attempt:
jQuery(document).ready(function($) {
if ( $( 'div.wp-caption' ).next().is( "p:contains(' ')" ) ) {
$( "p" ).remove( ":contains(' ')" );
}
});