Elegant Scroll to Top - Back to top JavaScript plugin example – Scroll: scroll to an element by ID
You can check out the code below to set the parameters.
Scroll: scroll to an element by ID
Example code
<link rel="stylesheet" href="http://your-domain.com/elegant-scroll-to-top/css/elegant-scroll-to-top.min.css">
<script src="http://your-domain.com/elegant-scroll-to-top/js/elegant-scroll-to-top.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
var elegantScrollToTop = new ElegantScrollToTop({
id: 'whats-this'
});
elegantScrollToTop.init();
});
</script>
Related options
| Peoprty | Possible Values | Default Value | Description |
|---|---|---|---|
| id | e.g. null, 'your-custom-id-1', 'your-custom-id-1', etc. | null | The id attribute of the element you want to scroll to. If the value is null, the browser scrolls to top of the page. In this case, you do not need to change this parameter. Most users leave this setting by default. |
Scroll down to view the Scroll to Top button
You can see it now