Skip to content
Related Articles

Related Articles

How to detect the user’s device using jQuery ?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 24 Jun, 2019

The task is to determine the user’s device, whether it is iPad or not, using JQuery. Below are the required methods:

  • Navigator userAgent Property:
    This property returns the value of the header of user-agent which is sent by the browser to the server.
    Returned value, have information like name, version, and platform of the browser.



    Return value:
    It returns a string, which represents the user agent string of the current browser.

Example: This example uses the navigator.userAgent property to identify the user’s device.

      | Detect iPad users.
<script src=
<body style="text-align:center;" 
    <h1 style="color:green;">  
    <p id="GFG_UP" 
       style="font-size: 17px; 
              font-weight: bold;">
        click here
    <p id="GFG_DOWN" 
       style="color: green; 
              font-size: 24px; 
              font-weight: bold;">
          "Click on the button to see "+
          "whether user's device is iPad or not");
        $('button').on('click', function() {
            var is_iPad = 
                navigator.userAgent.match(/iPad/i) != null;


  • Before reaching the bottom:
  • After reaching the bottom:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!