-
-
Save raihan004/971aa20b7ca28098b790468f8383320b to your computer and use it in GitHub Desktop.
Remove empty <p> tags with jQuery.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove empty <p> tags. | |
* | |
* See: http://stackoverflow.com/questions/27781798/wordpress-retain-formatting-when-calling-extended-content#comment43990361_27782619 | |
* This seems to be the easiest solution. Remove this function if this ever gets fixed. | |
* Credits: http://stackoverflow.com/questions/6092855/how-do-i-remove-empty-p-tags-with-jquery | |
*/ | |
( function( $ ) { | |
$( 'p' ).each( function() { | |
var $this = $( this ); | |
if ( $this.html().replace( /\s| /g, '' ).length === 0 ) { | |
$this.remove(); | |
} | |
}); | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment