Skip to content

Instantly share code, notes, and snippets.

@gregglind
Last active August 29, 2015 14:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregglind/88d08adaee461dbf16f4 to your computer and use it in GitHub Desktop.
Save gregglind/88d08adaee461dbf16f4 to your computer and use it in GitHub Desktop.
Idea for making all ids on a reports page have a para link.
/** js **/
/** or this could be in the page template, if adding an 'a' there is easier **/
/* 'after' was chosen for laziness/simplicity of styling. */
/* if you to get *all things with ids
$(".content").find("p, ul, ol, pre, h1, h2, h3, h4, h5, h6") # more restrictive
*/
$(".content").find("*").each( function (k, v) {
var id = v.id;
if (!id) return;
console.log(id);
$(this).append($("<a>&#182;</a>").addClass("anchor").attr({"href":"#"+id}));
});
$("a.anchor").parent().hover(function(){$(this).find('a').addClass('visible');},
function(){$(this).find('a').removeClass('visible');});
/** css **/
.anchor {
visibility: hidden;
color: inherit;
position: absolute;
margin-left: 10px;
}
.anchor:hover, .anchor:visited, .anchor:link, .anchor:active
{
text-decoration: none;
}
.visible {
visibility: visible;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment