Home Page DOM Tutorials Using Events Implementing showMenu() |
All that remains now is to implement the showMenu() function, which is shown below. The line numbers are only for reference.
1 function showMenu( evt ) 2 { 3 var owner = findOwner( evt ); 4 5 var divNum; 6 7 divNum = owner.attributes.getNamedItem("id").nodeValue; 8 9 divNum = parseInt( divNum.substr(1) ); 10 11 if (getIdProperty( "s" + divNum, "display") != "block" ) 12 { 13 setIdProperty("s" + divNum, "display", "block"); 14 document.images["i" + divNum].src = "../minus.png"; 15 } 16 else 17 { 18 setIdProperty("s" + divNum, "display", "none"); 19 document.images["i" + divNum].src = "../plus.png"; 20 } 21 }
Here are the lines of interest:
Finding the div | Index | Summary |