/Anchor-JS

A JavaScript utility for adding anchor links to page content.

Primary LanguageJavaScriptMIT LicenseMIT

Anchor-JS

A JavaScript utility for adding anchor links to page content.

Demo

Try it

Codepen

Installation

CDN

<script src="https://cdn.jsdelivr.net/gh/AdrianVillamayor/Anchor-JS@main/src/anchor.min.js"></script>

Manual

<script src="/js/plugins/anchor.js"></script>

Usage

$('.anchor[data-anchor]').on("click", function(e) {
    e.preventDefault();

    let target = $(this).attr("data-anchor");     

    scrollToAnchor(target);
})

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Thanks for your help! 🎉