Add href to heading anchors so that the url for the anchor is displayed in the url bar when clicking the header

This commit is contained in:
Mathieu David 2016-01-01 02:17:40 +01:00
parent bb0c878e06
commit a7f329d337
3 changed files with 17 additions and 0 deletions

View File

@ -12,6 +12,14 @@ body {
.hidden {
display: none;
}
a h1,
a h2,
a h3,
a h4,
a h5 {
color: #000;
pointer: cursor;
}
h2,
h3 {
margin-top: 2.5em;

View File

@ -56,6 +56,8 @@ $( document ).ready(function() {
content.find("h1, h2, h3, h4, h5").wrap(function(){
var wrapper = $("<a class=\"header\">");
wrapper.attr("name", $(this).text());
// Add so that when you click the link actually shows up in the url bar...
wrapper.attr("href", $(location).attr('href') + "#" + $(this).text());
return wrapper;
});

View File

@ -15,6 +15,13 @@ html, body {
display: none;
}
a {
h1, h2, h3, h4, h5 {
color: black;
pointer: cursor;
}
}
h2, h3 { margin-top: 2.5em }
h4, h5 { margin-top: 2em }