I need a way to overwrite my elements that are set to pointer-events:none. I have already tried a few things, but it doesn't seem to be able to control the elements under this setting.
const meinElement = document.getElementById('hovertest');
meinElement.addEventListener('mouseenter', function() {
meinElement.style.pointerEvents = "none";
meinElement.classList.add('hovered');
});
meinElement.addEventListener('mouseleave', function() {
meinElement.style.pointerEvents = "none";
meinElement.classList.remove('hovered');
});
#hovertest {
width: 100px;
height: 100px;
border: 1px solid red;
position: absolute;
z-index: 999999999999999999999999999999999999999999999999999999999;
}
.hovered {
background-color: red;
pointer-events: auto;
}
I have already tried this suggestion, which didn’t work. JavaScript setting pointer-events
I expected the JS to override the setting, but that is not the case.
You have to delete the
meinElement.style.pointerEvents = "none";because when you add this it willhoveronly one time and add. It happens because when you set it to "none"; it can't be changed anymore. Add CSS cursor property when using "pointer-events: none"