How to use the discovery function to find out if the browser supports css hover?

How can I use function detection to determine if the browser supports the pseudo-class: hover? I want to do this WITHOUT using conditional comments to include, possibly, ie6 specific files.

+4
source share
2 answers

If it is equal to ie6 or older, it does not support hovering. Any other browsers that do not support freezing are too old and unclear to worry about.

EDIT

You can do the work :hover , i.e. 6: See here

+1
source

The hover class pseudo-class is supported by standardized browsers. Browsers such as IE6 will only support it for <a> elements.

However, you can use hover changes on any thing using jQuery to name it.

 $('.class').hover( function(){ $(this).addClass('hover'); }, function(){ $(this).removeClass('hover'); }); 

In your css, use the .hover class instead of pesudo-class: hover

+1
source

Source: https://habr.com/ru/post/1339066/


All Articles