'How do I prevent the next url redirect from happening when a button is clicked?

I've created a single page that uses a button and anchor links to navigate. So when you click the button, it takes you to the first section ("index.html#one") and when you click again it takes you to second section ("index.html#two") and so on. But because each if statements meet the condition, every command fires up simultaneously. Now when you click the button once instead of going to index.html#two it goes straight to index.html#three. How do I prevent this from happening?

$( "button" ).click(function() {
        if(window.location.href === "index.html#one"){
            window.location = "#two";
           }
        if(window.location.href === "index.html#two"){
            window.location = "#three";
           }
    });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source