Last active
August 29, 2015 14:08
-
-
Save gregglind/88d08adaee461dbf16f4 to your computer and use it in GitHub Desktop.
Revisions
-
gregglind revised this gist
Nov 7, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -17,6 +17,8 @@ $("a.anchor").parent().hover(function(){$(this).find('a').addClass('visible');}, function(){$(this).find('a').removeClass('visible');}); /** css **/ .anchor { visibility: hidden; -
gregglind created this gist
Nov 7, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ /** 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>¶</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; }