Bohemian
Bohemian

Reputation: 51

How can I keep the button disable of previous page even after I visiting next page or after refreshing previous

This is my code but it enable the button after refreshing

function disablebtn(){
    $("input[type=checkbox]").prop("disabled", true);
    $(".buttons11").prop("disabled", true);
    return true;
}

Upvotes: 3

Views: 78

Answers (1)

nashcheez
nashcheez

Reputation: 5183

You should use HTML5 Web storages for such requirements.

The following code should provide you an idea:

// For after refresh or later navigation to the page
if (localStorage.btnStatus === "disabled") {
    disablebtn();
}

function disablebtn() {
    $("input[type=checkbox]").prop("disabled", true);
    $(".buttons11").prop("disabled", true);
    localStorage.btnStatus = "disabled";
    return true;
}

Upvotes: 2

Related Questions