Answers for "javascript go to id"

-1

js scroll to id

// Js
document.getElementById('id').scrollIntoView();

// JQuery
$('#id')[0].scrollIntoView();
Posted by: Guest on August-13-2020
0

a go to id js

//scroll to id
    var $root = $('html, body');
    $('a[href^="#"]').click(function () {
        var href = $.attr(this, 'href');
        $root.animate({
            scrollTop: $(href).offset().top
        }, 500, function () {
            window.location.hash = href;
        });

        return false;
    });
Posted by: Guest on September-14-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language