I kind of know how Modernizr works, by adding a Class to the <html> element, I know that jQuery Browser Detection is deprecated, is there a way to detect and add a class ?
I kind of know how Modernizr works, by adding a Class to the <html>
Share
Detecting a browser is not difficult (though generally not recommended and occasionally inaccurate). If you’re familiar with modernizr, then you should know that feature detection is much more maintainable and accurate mechanism for identifying which behavior you should use in the host browser. For actual browser detection (again, not recommended), I’d suggest reading this Mozilla article: https://developer.mozilla.org/En/Browser_Detection_and_Cross_Browser_Support.
For setting a class, that’s much easier. To set a class on the body object, you would just do this:
or to add a class, you would use this: