To check if the userAgent is a mobile device in jQuery you can use the following snippet.
It will match the following:

  • • Android
  • • webOS
  • • iPhone
  • • iPad
  • • iPod
  • • BlackBerry

Sample jQuery

if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/.test(navigator.userAgent) ) {
	// mobile device
} 
else 
{
	// other device
}

2 thought on “How to check if a userAgent is a mobile device in jQuery”

Leave a Reply