I am a beginner and I am trying to override that the :hover pseudo-class in CSS doesn't let me trigger an event if the element that I am hovering over is below some other element.
If I hover over the div, the css transition kicks in, however, if I go over the text that is visually above the div, nothing happens.
I have four such elements, so I was trying to use getElementsByClassName to create the array to be iterated in JavaScript, but the console gives me always the same error of
index.html:77 Uncaught TypeError: Cannot read property 'style' of
undefined
at stretchback (index.html:77)
at HTMLParagraphElement.onmouseout (index.html:24)
stretchback @ index.html:77
onmouseout @ index.html:24
<script>
var boxes = document.getElementsByClassName('skill-box');
function stretch() {
for (var i=0; i < boxes.length; i++)
boxes[i].style.opacity = "0.3";
boxes[i].style.transform = "scaleY(10)";
boxes[i].style.borderRadius = "0px";
boxes[i].style.transition = "opacity 2s, transform 2s, border-radius 1s ease-in-out";
}
function stretchback() {
for (var i=0; i < boxes.length; i++)
boxes[i].style.opacity = "1";
boxes[i].style.transform = "scaleY(1)";
boxes[i].style.borderRadius = "10px";
boxes[i].style.transition = "opacity 2s, transform 2s, border-radius 1s ease-in-out"; }
</script>
What am I doing wrong?
i < document.getElementsByClassName('skill-boxes').length;The performance of that is bad.box, which should really be plural by the way). So if anything changes the state of the DOM then those lengths might not always be equal.