How do I remove :hover?

前端 未结 9 774
南方客
南方客 2020-12-15 03:41

I have a small problem with a script.
I want to have a default action on :hover for clients with Javascript disabled, but for those with Javascript enabled

9条回答
  •  Happy的楠姐
    2020-12-15 04:36

    You can redraw element after click
    function redraw(element) {
    if (!element) { return; }
    
    let n = document.createTextNode(' ');
    let disp = element.style.display;  // don't worry about previous display style
    
    element.appendChild(n);
    element.style.display = 'none';
    
    setTimeout(function(){
        element.style.display = disp;
        n.parentNode.removeChild(n);
    }, 100); // you can play with this timeout to make it as short as possible
    

    }

提交回复
热议问题