Category Archives: Html

How to track changes in a page using jquery

Let as imagine, we need to show the user a confirmation message when he changed something in a page and tries close the page, how to do it ?. Well, here I am presenting a simple way to do that with jquery.
First step is to add a hidden element in your html code

Assuming that you have added the jquery library already, add the following javascript code in your page

Hurrey, you are done. Now if you changed anything in your page and tries to close your page before it is saved, the page will show a confirmation message. However, if you are saving the data using ajax, do not forget to set the value of “haveChanges” to false after saving. So that was it, cheers and happy coding fellas.