Test if Mac or PC with JavaScript

Submitted by:Jhon Smith

Date added:29 December, 2016

Category:JavaScript

JavaScript code snippet to test if Mac or PC

Tags: navigator , user agent

Code Snippet:

if (navigator.userAgent.indexOf('Mac OS X') != -1) {
$("body").addClass("mac");
} else {
$("body").addClass("pc");
}
 
 

Comments