Thursday, August 17, 2006

Hiding all Checkboxes on a HTML Page with Javascript

Iterating through all the checkbox elements on a page using the javascript getElementsByTagName() command.

var inputs = window.document.getElementsByTagName('input');

for(var i=0; i < inputs.length; i++){ //iterate through all input elements
if (inputs[i].type.toLowerCase() == 'checkbox') { //if the element is a checkbox
inputs[i].style.display = "none";
}
}


No comments:

Post a Comment