尝试在页面刷新时保持启用/禁用状态的复选框

时间:2018-04-16 20:38:01

标签: javascript jquery

我在这里有一些代码,用于在单击复选框时启用/禁用提交按钮。这工作正常,但我需要禁用/启用状态以保持页面刷新

$(document).ready(function() {
        var the_terms = $("#tandcCheck");
        the_terms.click(function() {
            if ($(this).is(":checked"))
                $(".submit").removeAttr("disabled");
            } else {
                $(".submit").attr("disabled", "disabled");  
            }
        });
    });

Cookie是最佳选择还是会话?

1 个答案:

答案 0 :(得分:1)

对HTML的任何修改都不会在页面调用之间持续存在。是的,cookie会起作用,但我建议 localStorage 更简单:

    def kthPrime(self, n):
            if n>10 and n%10 not in [1,3,7,9]:
                return 0
            if n == 2:
                return 1
            queue = []
            num = 2
            while num <= n:
                if n%num == 0 and num != n:
                    return 0
                if num>10 and num%10 not in [1,3,7,9]:
                    num += 1 
                    continue
                for i in range(2,num/2+1):
                    if num%i == 0:
                        num += 1 
                        break
                else:    
                    queue.append(num)
                    num += 1
            seq = queue.index(n) + 1
            return seq