Clear Form on Back Button?

后端 未结 4 939
太阳男子
太阳男子 2020-12-16 04:46

I have a page with several check-boxes in a form, which when selected, filter corresponding info out of a table with jquery. My problem is the following scenario:

4条回答
  •  爱一瞬间的悲伤
    2020-12-16 05:23

    Do not allow your page to be cached, or add code to reset your form:

    $("form input").each(function(){
        var elem = $(this);
        var type = elem.attr("type");
        if(type == "checkbox") elem.prop("checked", "");
        else if(type == "text") elem.val("");
    });
    

    .each has to be used, because the CSS selector input[type=text] doesn't match , while the element is still a text element.

提交回复
热议问题