Last active
January 18, 2024 10:50
-
-
Save stemar/327e34a0b2bebd11adb5 to your computer and use it in GitHub Desktop.
Adding target="_blank" or any other attribute to a Markdown link
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
Markdown: | |
[JP Markdown](https://wordpress.org/plugins/jetpack-markdown){.target-blank .rel-nofollow} | |
JavaScript (just before the closing </body> tag): | |
<script> | |
jQuery('.target-blank').attr('target', '_blank').removeClass('target-blank').filter('[title=""]').removeAttr('title').filter('[class=""]').removeAttr('class'); | |
jQuery('.rel-nofollow').attr('rel', 'nofollow').removeClass('rel-nofollow').filter('[title=""]').removeAttr('title').filter('[class=""]').removeAttr('class'); | |
</script> | |
Post-jQuery HTML: | |
<a href="https://wordpress.org/plugins/jetpack-markdown" target="_blank" rel="nofollow">JP Markdown</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment