Home>

I'm trying to implement smooth scrolling using smooth-scroll.js, but isn't it possible to do smooth scrolling with the button tag instead of the a tag?
Is it possible to execute a [href * = "#"] as button [class = "head-btn"]?

  • Answer # 1

    If you look at the implementation of smooth-scroll.js, it seems that tags other than a tag are not supported.
    The button tag is not likely to work.

    // Returned by the condition judgment in the clickHandler of smooth-scroll.js
    // If it is not an a tag, return and do nothing
    if (! toggle || toggle.tagName.toLowerCase ()! == 'a' || event.target.closest (settings.ignore)) return;

    Source: smooth-scroll.js (v16.1.0) # L514-GitHub

    If you really need to use smooth-scroll, it's better to mess with CSS and make the a tag look like a button.

  • Answer # 2

    Thank you. I should have confirmed it properly.
    It was solved by remodeling the a tag like a button!