var ua = navigator.userAgent.toLowerCase()
if (/iphone|ipad|ipod/.test(ua)) {
$(".ios").show()
} else if (/android/.test(ua)) {
$(".az").show()
}
<script type="text/javascript">/**
* [judgeOs 用户代理判断]
* @return {[type]} [description]
*/
function judgeOs() {
var ua = navigator.userAgent,
isWindowsPhone = /(?:Windows Phone)/.test(ua),
isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
isAndroid = /(?:Android)/.test(ua),
isFireFox = /(?:Firefox)/.test(ua),
isChrome = /(?:Chrome|CriOS)/.test(ua),
// 平板
isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
isPhone = /(?:iPhone)/.test(ua) && !isTablet,
isPc = !isPhone && !isAndroid && !isSymbian
return {
isTablet: isTablet,
isPhone: isPhone,
isAndroid : isAndroid,
isPc : isPc
}
},
// 资料参考HTML5学堂
</script>