Pages

Monday, December 28, 2009

Hide A HTML Element Using Javascript - A Cross Browser Solution

function hideElement(divId) {
var element;
// get the element referenced by the parameter elementID
if (typeof elementID === "string") {
element = document.getElementById(divId);
} else {
element = divId
}

if ((typeof element == 'undefined') || (element == null)) {
throw new Error(
'No element with id "' + divId + '" is found
- in function hideElement(divId)');
}
element.style.display = 'none';
}

No comments:

Post a Comment