0

Is there a way to programatically disable :hover in my whole HTML document and all child elements using Javascript, without using classes or jQuery ?

Mendes
  • 17,489
  • 35
  • 150
  • 263
  • you can use all selector but support is limited https://developer.mozilla.org/en-US/docs/Web/CSS/all – sumeet kumar Nov 15 '17 at 21:53
  • I think this is already answered https://stackoverflow.com/questions/2754546/can-i-disable-a-css-hover-effect-via-javascript – FelipeM Nov 15 '17 at 21:54
  • @FelipeM Ehhh kind of, that is using classes, and you don't know what to *not* do on all dom elements, unless you go through and document every single thing that happens on hover and undo it in your new hover rule, which I think is going against what the OP wants – mhodges Nov 15 '17 at 21:57
  • @mhodges it's probably the best basis for an answer though. Really, this is what I'd consider an unnatural act. – Pointy Nov 15 '17 at 21:58
  • @Pointy This the solution to that question uses classes - this question specifically asks for a solution that does not use classes. Please consider re-opening – mhodges Nov 15 '17 at 21:58
  • @mhodges well that's a good point, but I fear that the real answer then is "no". – Pointy Nov 15 '17 at 22:00
  • @Pointy Agreed, I think the answer is no. – mhodges Nov 15 '17 at 22:02
  • @mhodges I wonder if it'd work to throw up an absolutely-positioned `
    ` with a transparent background over the whole page? I think that would block `:hover`, but it would of course also block all other page interactions.
    – Pointy Nov 15 '17 at 22:04
  • @Pointy Right, which would essentially be like doing `pointer-events: none`, unfortunately, I think it would have unintended consequences – mhodges Nov 15 '17 at 22:10

0 Answers0