-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex-copy.html
36 lines (36 loc) · 1.02 KB
/
index-copy.html
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
<!DOCTYPE html>
<html>
<head>
<title>Title of the Document</title>
<script src="https://code.jquery.com/jquery-3.5.0.min.js"></script>
<style>
#textDiv {
height: 1500px;
}
p {
margin-top: 100px;
height: 500px;
}
</style>
</head>
<body>
<div id='linkDiv'>
<a href="#link1" class="scrollLink">Scroll to link1</a>
<a href="#link2" class="scrollLink">Scroll to link2</a>
</div>
<div id="textDiv">
<p id="link1"><strong>Anchor 1</strong> - Lorem ipsum dolor sit amet, nonumes voluptatum mel ea.</p>
<p id="link2"><strong>Anchor 2</strong> - Ex ignota epicurei quo, his ex doctus delenit fabellas.</p>
</div>
<script>
$(document).ready(function() {
$("a.scrollLink").click(function(event) {
event.preventDefault();
$("html, body").animate({
scrollTop: $($(this).attr("href")).offset().top
}, 500);
});
});
</script>
</body>
</html>