<p>I'd like to track changes in inputs in a form via javascript. My intent is (but not limited) to</p>

<ul>
<li>enable "save" button only when something has changed</li>
<li>alert if the user wants to close the page and something is not saved</li>
</ul>

<p>Ideas?</p>

Loop through all the input elements, and put an
```
onchange
```
handler on each. When that fires, set a flag which lets you know the form has changed. A basic version of that would be very easy to set up, but wouldn't be smart enough to recognize if someone changed an input from "a" to "b" and then back to "a". If it were important to catch that case, then it'd still be possible, but would take a bit more work.
Here's a basic example in jQuery:
```
```
$("#myForm")
    .on("input", function() {
        // do whatever you need to do when something's changed.
        // perhaps set up an onExit function on the window
        $('#saveButton').show();
    })
;
```
```