`style` property is `null` on element

davidb834

New Member
I have this code:\[code\]function displayMenu (newGal, newSub) { curGal = newGal; curSub = newSub; if (curGal == null) { curGal = "main"; }; arrayL = curGal.length; if (curImg == null) { curImg = 0; }; if (curSub == null) { curSub = 0; }; prevImg = curImg - 1; if (prevImg == null || prevImg < 0) { prevImg = arrayL; }; nextImg = curImg + 1; document.getElementById('img1').style.display = "none";};\[/code\]And no matter what it's giving me that the \[code\]style\[/code\] property is \[code\]null\[/code\]. This code is massively torn down from what it used to be; this was part of a \[code\]for\[/code\] loop that was supposed to use \[code\]i\[/code\] to target \[code\]"img" + i\[/code\] to select the \[code\]div\[/code\]s with the \[code\]id\[/code\] of \[code\]img0\[/code\]-\[code\]9\[/code\], then I broke it down and tried manually targeting every single \[code\]img0\[/code\]-\[code\]9\[/code\] with a separate line and it just keeps breaking. Yes, the \[code\]img0\[/code\]-\[code\]9\[/code\] divs are in the HTML. The original \[code\]for\[/code\] loop looked like this:\[code\]for (i = 0; i < array.L; i++) { var tempButton = "img" + i; document.getElementById(tempButton).style.display = "none";};\[/code\]Why is the \[code\]style\[/code\] property \[code\]null\[/code\], and how can I fix it?
 
Top