I get error of code Unable to get property 'style' of undefined or null reference
with this function. I am setting the style of all the elements in the array.
For the record all answers do not address the problem here. If you look at the code it is quite clear the big problem is the curly brackets, one is backwards and there is one extra. The one backwards is the one that is the big problem and why I got errors and why alert worked, as alert is called before the error is read". I think.
I knew I was missing something simple, and is why I posted this. Most programming problems I see here are syntax errors, and are most of my issues when things don't work.
Working on all time low-rep, so please add your vote. THANK YOU.
function marc()
{
if(navigator.appVersion === "5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko")
{
var x=document.getElementsByClassName('nav_top'), i=x.length;
if(i===x.length)
{
// alert("works now); this works
x[i].style.margin = "0px -2.2px -1px -2.2px";//this line pulls the error
}
}
}
I have tried change the quotes and removing the quotes which changes the error to the function undefined.