Generic way to detect if html form is edited

后端 未结 7 1129
悲&欢浪女
悲&欢浪女 2020-11-30 18:41

I have a tabbed html form. Upon navigating from one tab to the other, the current tab\'s data is persisted (on the DB) even if there is no change to the data.

I woul

7条回答
  •  北海茫月
    2020-11-30 19:25

    I am not sure if I get your question right, but what about addEventListener? If you don't care too much about IE8 support this should be fine. The following code is working for me:

    var form = document.getElementById("myForm");
    
    form.addEventListener("input", function () {
        console.log("Form has changed!");
    });
    

提交回复
热议问题