When we Developing Site like in HTML, WordPress, Magento etc…, Sometimes you may need browsers and operating System information to modify some section by using css . jQuery able of doing that for you . In this article you will learn how to add browser and operating system classes in body tag.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
jQuery(document).ready(function() { // Get browser Browser Information jQuery.each(jQuery.browser, function(i) { jQuery('body').addClass(i); return false; }); // Get OS Information var os = [ 'iphone', 'ipad', 'windows', 'mac', 'linux' ]; var match = navigator.appVersion.toLowerCase().match(new RegExp(os.join('|'))); if (match) { jQuery('body').addClass(match[0]); }; }); |
Presently you can create css for browser or operating systems specific or you can use them as selectors in jquery