jquery简单判断PC端还是移动端?

1 $(function(){
2  if (!navigator.userAgent.match(/mobile/i)) {
3 //PC端
4         }else{
5 //移动端
6 }
7 })