I've been working on this, and it's very nearly working. I have a feeling that the setInterval inside the loop is something that can't be done, or isn't working. Without the setInterval and the final 'if' statement, it loops through the elements perfectly and adds a className to each if I set it to. Here's my script if anyone can advise as to where I am going wrong:
(function() {
var localStorageID = document.getElementById('local-storage');
var inputTags = ['input', 'textarea', 'select', 'button'];
// Loop through all the input tags on the page
for(var i = 0; i < inputTags.length; i++) {
// Create a variable that matches input tags inside our #localStorage
var localStorageTag = localStorageID.getElementsByTagName(inputTags[i]);
var formData = {};
for(var z = 0; z < localStorageTag.length; z++) {
formData[localStorageTag[z].name] = localStorageTag[z].value;
}
localStorage.setItem('formData', formData);
if(localStorage.getItem('formData')) {
// Try to achieve something
}
}
})();