four0four
06-20-2008, 02:54 AM
Hi,
I'm trying to fix a script that does a search for all links on a page and applies a display:none style to each one.
Here's what I have so far:
<html>
<head>
<title>Test</title>
</head>
<body>
<a href="#">Remove this link</a>
<script>
alink = document.getElementsByTagName("a");
for (i=0; i <= alink.length; i++){
alink[i].style.display = "none";
}
</script>
</body>
</html>
When loading the script in IE it says:
alink[...].style is null or not an object
Does anyone know how to fix this?
Thanks!
I'm trying to fix a script that does a search for all links on a page and applies a display:none style to each one.
Here's what I have so far:
<html>
<head>
<title>Test</title>
</head>
<body>
<a href="#">Remove this link</a>
<script>
alink = document.getElementsByTagName("a");
for (i=0; i <= alink.length; i++){
alink[i].style.display = "none";
}
</script>
</body>
</html>
When loading the script in IE it says:
alink[...].style is null or not an object
Does anyone know how to fix this?
Thanks!