htmlbuttonpage-jump

How Do I Jump To The Bottom Of A Page After New Table Entry In HTML?


I'm trying to make an HTML button on the top of the page (above a table) add a new table entry, and jump to the bottom of the page at the same time so that the new entry is visible. The button already adds the new entry like this

onclick="addrange()"

What can I add to the button to make it jump to the bottom of the page in addition to the new entry, all in one press?

Thanks.


Solution

  • you can try this code:-

    function addrange(){
    
        //Your code
    
        //code for scrolling down
        document.body.scrollTop = document.body.scrollHeight - document.body.clientHeight;
    
    }