// JSON Array
var FormFields = {"elements": [
{"id": "firstName"},
{"id": "lastName"},
{"id": "address"},
{"id": "city"},
{"id": "zip"},
{"id": "email"}
]
};
// What style do you wish to apply to the border
updateStyle('2px solid #9090f9');
// Function to loop through elements
function updateStyle(s) {
foreach(FormFields.elements as FormField) {
document.getElementById(FormField.id).style.border = s;
}
}
function $(element) {
if (arguments.length > 1) {
for (var i = 0, elements = [], length = arguments.length; i < length; i++)
elements.push($(arguments[i]));
return elements;
}
if (Object.isString(element))
element = document.getElementById(element);
return Element.extend(element);
}
Open in new window
and now your code become :
Open in new window