tim@toky
07-17-2007, 06:18 PM
I'm stumped as to why this is happening. I'm just trying to do a simple rollover and adjust the position of the background image on each anchor tag. I am getting an error on each mouseover that the element has no properties. Any help would be greatly appreciated. Thanks in advance.
The markup:
<div id="header-wrapper">
<ul id="main-nav">
<li id="our-mission">
<a href="#">Our Mission</a>
</li>
<li id="insight-reviews">
<a href="#">Insight & Reviews</a>
</li>
<li id="how-we-can-help">
<a href="#">How We Can Help</a>
</li>
<li id="who-we-are">
<a href="#">Who We Are</a>
</li>
<li id="tools-techniques">
<a href="#">Tools & Techniques</a>
</li>
</ul>
<div style="clear:both;"></div>
</div>
The script:
function init(){
var els = document.getElementById("main-nav");
var links = els.getElementsByTagName("a");
var index = 0;
for(index; index < links.length; index++){
links[index].onmouseover = function(){
links[index].style.backgroundPosition = "bottom";
}
}
}
window.onload = init;
The markup:
<div id="header-wrapper">
<ul id="main-nav">
<li id="our-mission">
<a href="#">Our Mission</a>
</li>
<li id="insight-reviews">
<a href="#">Insight & Reviews</a>
</li>
<li id="how-we-can-help">
<a href="#">How We Can Help</a>
</li>
<li id="who-we-are">
<a href="#">Who We Are</a>
</li>
<li id="tools-techniques">
<a href="#">Tools & Techniques</a>
</li>
</ul>
<div style="clear:both;"></div>
</div>
The script:
function init(){
var els = document.getElementById("main-nav");
var links = els.getElementsByTagName("a");
var index = 0;
for(index; index < links.length; index++){
links[index].onmouseover = function(){
links[index].style.backgroundPosition = "bottom";
}
}
}
window.onload = init;