How do I remove empty p tags with jQuery?

后端 未结 6 893
后悔当初
后悔当初 2020-12-04 22:32

The platform I\'m building a website on produces empty p tags in wysiwyg mode. How can I take these out?

Something like this, perhaps...

$

6条回答
  •  孤城傲影
    2020-12-04 22:49

    /* Remove empty paragraphs with   */
    jQuery('p').each(function(){
        if( jQuery(this).html() == ' ' )
            jQuery(this).remove();
    })
    

提交回复
热议问题