April 10, 2019
When adding content, sometimes it’s necessary to add in extra non-breaking spaces to adjust spacing on desktop. Even some plugins (Shortcodes Ultimate) will create additional paragraph tags in the content area that cannot be removed from the editor.
The below snippet allows you to target non-breaking spaces, and empty paragraph tags to remove them.
This comes in handy especially on handheld devices when the layout collapses, and the larger gaps are more noticeable.
jQuery("p").filter( function() { var html = jQuery(this).html(); if(html == '' || html == ' ') return true; }).addClass('emptyP');