I want to display explainer cards when the element is hovered. However, I only want to display it after it has been hovered for some time (eg 5 secs). I don’t think this is possible with bubble in built features.
I tried animations but they keep going on even if I stopped hovering the element, also it is still not a delayed response just a slower one.
I also tried introducing a delay but I cannot check whether it is still hovered after the delay. I tried adding a hide element when the element is stopped being hovered but while it helped with the animations it would still be buggy if I hovered too quickly.
I tried custom JS as well. However it would only work if I created all elements involved in the code within that HTML block. It seems like .getelementbyID() does not work on bubble elements.
thank you for your quick response. I was using getElementById(), sorry for the confusion I caused by misspelling it.
I found that it is not working using the getElementById() but it is working using querySelector().
One more issue I am facing is that it only works when I want to hide the element but not of it is hidden and I want to make it appear.
The code I am using is:
<script>
// Get the element
const testElement = document.querySelector("#test1");
// Change visibility using JavaScript
function toggleVisibility() {
if (testElement.style.display === 'none') {
testElement.style.display = 'block';
} else {
testElement.style.display = 'none';
}
}
setTimeout(toggleVisibility, 5000);
</script>
I found that it is not working using the getElementById() but it is working using querySelector().
One more issue I am facing is that it only works when I want to hide the element but not of it is hidden and I want to make it appear.
The code I am using is:
<script>
// Get the element
const testElement = document.querySelector("#test1");
// Change visibility using JavaScript
function toggleVisibility() {
if (testElement.style.display === 'none') {
testElement.style.display = 'block';
} else {
testElement.style.display = 'none';
}
}
setTimeout(toggleVisibility, 5000);
</script>
I placed an element with the ID #test1 on the screen. When I set its visibility to yes it disappears. When I hide it and reload the page the element does not appear.