tried to find a way to change a main image when hovering over an LI
Looking at Using only CSS, show div on hover over <a> I thought I could make it work, but when I moved the div it of course no longer worked.
Here is how I would do it with JavaScript - can you show me how to do the same with pure CSS on the same html?
<html>
<head>
<script>
var myImages = {li1:"image1.jpg",li2:"image2.jpg",li3:"image3.jpg"};
window.onload=function() {
var lis = document.getElementById('myList').getElementsByTagName('li');
for (var i=0;i<lis.length;i++) {
lis[i].onmouseover=function() {
document.getElementById('image1').src=myImages[this.id];
}
}
}
</script>
</head>
<body>
<img id="image1" />
<ul id="myList">
<li id="li1">show image1</li>
<li id="li2">show image2</li>
<li id="li3">show image3</li>
</ul>
</body>
</html>