Input fields are retaining their values after a page refresh, how to prevent that?

后端 未结 2 1256
借酒劲吻你
借酒劲吻你 2020-12-19 17:33
Post Your comment
N
2条回答
  •  囚心锁ツ
    2020-12-19 17:56

    I believe this is a browser thing, not a code thing.

    However, if you want to override the default behavior when the page has loaded, try running (jQuery):

    $(function(){
        $( 'textarea, input[type=text]' ).val('')
    });
    

    or (pure Javascript):

    var load = function()
    {
        document.forms[0].elements["username"].Value =
            document.forms['postform'].elements["text"].Value = '';
    }
    

    in the body tag of your page add: onLoad=load()

提交回复
热议问题