Quote:
Originally Posted by aa1037
I'm doing an assignment for my web design class and there is a chunk of code I need to describe and I'm not quite sure what is going on in it.
Code:
function makeappear() {
if (document.getElementById('row2').style.display == ") {
document.GetElementById('row2').style.display = 'none';
} else {
document.getElementById('row2').style.display = ";
}
Thanks in advance!
|
document.getElementByID('row2').style.display
This line finds the 'display' property of the 'style' field in an element named 'row2' somewhere in the 'document'. 'Document' being the webpage the script was run on. 'row2' 'element' being something that a 'style' field can be applied to such as a <div> tag or a <a> tag or a <p> tag. 'Display' being a property of the 'style' field which indicates the current status of the 'element'- whether it's visible or not.
if (document.getElementById('row2').style.display == ")
document.GetElementById('row2').style.display = 'none';
If the display property is equal to whatever " represents then set the display property to equal 'none'. When the display property is none, then the element is not drawn. For example: If perhaps, the element was a <div>, then everything in between the <div name=row2></div> tags would be invisible.
} else {
document.getElementById('row2').style.display = ";
If the display field did not equal 'none' then we set the display field to equal whatever " represents.