Javatpoint Logo
Javatpoint Logo

How to Detect a Mobile Device in jQuery

If we want to search for a particular user, a list of JavaScript syntaxes is given below that can be used to identify different mobile devices such as iPod, iPad, Android, Blackberry, Windows Phone and WebOS etc.

Syntax

A Basic example

Here, we have the most basic code to detect the mobile phone using jQuery.

Supportive Browsers

The syntaxes mentioned above and code support the following browsers:

  • Safari
  • Google Chrome
  • Mozilla Firefox
  • Microsoft Edge
  • Opera

Now, we are going to define the different syntactical logics for detecting various types of mobile phone.

For Detecting iPhone

You can search the iPhone with the help of following JavaScript code.

For Detecting iPod

A JavaScript code is given below to detect the iPod.

For Detecting iPad

Here, we have an illustration for detecting the iPad.

For Detecting Android Phone

You can detect the Android Phone with the help of following JavaScript code.

For Detecting the Blackberry Phone

You can detect the Blackberry Phone with the help of following JavaScript code.

For Detecting the iDevices

You can search for the iDevices with the help of following JavaScript code.

For Detecting the Windows Phone

You can search for the Windows phone with the help of below-given JavaScript code.

For Detecting the WebOs

You can detect the WebOs with the help of below-mentioned JavaScript code.

Here, we also have another method to detect the mobile phone with the help of window.matchmedia() method.

You can also use the JS window.matchMedia() method for searching a cellular device according to the CSS media query. It is the best and easiest approach to predict the mobile device.

Syntax

Example 1: Example code for desktop.

Output

You will obtained the following result after the efficient execution of the above code.

How to Detect a Mobile Device in jQuery

Example 2: Example code for the mobile phone.

Output

You will get the following outcome after the successful implementation of the above code.

How to Detect a Mobile Device in jQuery





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA