Created
June 13, 2017 05:36
-
-
Save ddikman/ffbd7faaf75a2ee2bcaa4f08cf055c2f to your computer and use it in GitHub Desktop.
Javascript snippet to iterate confluence table rows and create anchor links for each row
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
<script type="text/javascript"> | |
// first up, let's tag everything | |
jQuery("table.confluenceTable tr td:nth-child(4)").each(function(e){ | |
var col = jQuery(this); | |
var text = col.text(); | |
var encodedId = text.replace(/[^A-Za-z\d]/g, '_'); | |
col.attr("id", encodedId); | |
col.html('<a href="#' + encodedId + '">' + col.text() + '</a>'); | |
}); | |
if(window.location.hash.length > 0){ | |
var hash = window.location.hash.substr(1); | |
jQuery('tr').has('#' + hash).css("background-color", "Yellow"); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment