<div class="parent" tabindex="0">
Some stuff!
<a href="https://google.com" class="deal-with-focus-with-javascript">Link here</a>
</div>
div {
padding: 30px;
background: #eee;
opacity: 0;
}
div:hover,
div:focus,
div.focus {
opacity: 1;
}
body {
padding: 2rem;
}
View Compiled
var parent = document.querySelector(".parent");
parent.addEventListener("focusin", function() {
parent.classList.add("focus");
});
parent.addEventListener("focusout", function() {
parent.classList.remove("focus");
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.