I have a code that adds a red border around elements when you mouseover them and removes it when you mouseout.
However, the elements jump around when the border is added because it changes their dimensions. Is there a way to stop this jumping behavior?
document.addEventListener("mouseover", eOnMouseOver, true);
document.addEventListener("mouseout", eOnMouseOut, true);
function eOnMouseOver(e) {
e.target.style.border = "2px solid red";
}
function eOnMouseOut(e) {
e.target.style.border = "";
}
<div style="border:1px black solid;">Mouseover me</div>
<a href="#">Mouseover me</a>