-
-
Save tommcfarlin/51f84be9c72e86b67480 to your computer and use it in GitHub Desktop.
[JavaScript] How to remove empty `code` elements using jQuery.
This file contains 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
<p> | |
<code>This is my original multiline | |
comment that includes carriage returns</code> | |
<code> | |
</code> | |
<code> | |
and new lines throughout the comments. | |
</code> | |
</p> |
This file contains 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
<code>This is my original multiline | |
comment that includes carriage returns | |
and new lines throughout the comments. | |
</code> |
This file contains 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
( function ( $) { | |
'use strict'; | |
$( '.comment code' ).each(function() { | |
if ( '' === $.trim( $( this ).text() ) ) { | |
$( this ).remove(); | |
} | |
}); | |
}( jQuery ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment