var operatingSystem, userAgentString = navigator.userAgent; var link = $("#store"); if (userAgentString.indexOf("iPhone") > -1 || userAgentString.indexOf("iPod") > -1 || userAgentString.indexOf("iPad") > -1) { operatingSystem = "iOS"; link.attr("href", "http://store.apple.com/us/browse/app"); } else if (/Android/.test(userAgentString)) { operatingSystem = "Android"; link.attr("href", "https://play.google.com/store/apps?hl=en"); } else if (/Windows Phone/.test(userAgentString)) { operatingSystem = "Windows Phone"; link.attr("href", "http://www.windowsphone.com/en-us/store"); }