-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanchor.html
More file actions
41 lines (37 loc) · 1.16 KB
/
Copy pathanchor.html
File metadata and controls
41 lines (37 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!--
Author: Ray-Eldath
-->
<style>
.markdown-body .anchor{
float: left;
margin-top: -8px;
margin-left: -20px;
padding-right: 4px;
line-height: 1;
opacity: 0;
}
.markdown-body .anchor .anchor-icon{
font-size: 15px
}
</style>
<script>
$(document).ready(function() {
let nodes = document.querySelector(".markdown-body").querySelectorAll("h1,h2,h3")
for(let node of nodes) {
var anchor = document.createElement("a")
var anchorIcon = document.createElement("i")
anchorIcon.setAttribute("class", "fa fa-anchor fa-lg anchor-icon")
anchorIcon.setAttribute("aria-hidden", true)
anchor.setAttribute("class", "anchor")
anchor.setAttribute("href", "#" + node.getAttribute("id"))
anchor.onmouseover = function() {
this.style.opacity = "0.4"
}
anchor.onmouseout = function() {
this.style.opacity = "0"
}
anchor.appendChild(anchorIcon)
node.appendChild(anchor)
}
})
</script>