Target all anchor links and only scroll when target exists
This commit is contained in:
parent
601e443b3b
commit
e920b646c0
1 changed files with 4 additions and 2 deletions
|
@ -77,10 +77,12 @@ $('#scroll-top').on('click', function(event) {
|
||||||
scrollTo(0);
|
scrollTo(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#TableOfContents a').on('click', function(event) {
|
$('a[href^="#"] ').on('click', function(event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const target = $($(this).attr('href'));
|
const target = $($(this).attr('href'));
|
||||||
scrollTo(target.offset().top);
|
if (target.length) {
|
||||||
|
scrollTo(target.offset().top);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('[data-clipboard-text]').on('click', function(event) {
|
$('[data-clipboard-text]').on('click', function(event) {
|
||||||
|
|
Loading…
Reference in a new issue