Skip to content

Instantly share code, notes, and snippets.

@gregglind
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save gregglind/88d08adaee461dbf16f4 to your computer and use it in GitHub Desktop.

Select an option

Save gregglind/88d08adaee461dbf16f4 to your computer and use it in GitHub Desktop.

Revisions

  1. gregglind revised this gist Nov 7, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions para.tags.all.ids.txt
    Original 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;
  2. gregglind created this gist Nov 7, 2014.
    35 changes: 35 additions & 0 deletions para.tags.all.ids.txt
    Original 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>&#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;
    }