What's the best way to identify a mobile device?

  • 0
    What is the best way to set a condition and determine that a user entered the site from a mobile or tablet? In addition to the width, this parameter already seems to intersect at 1024.
    those. that there is no hover, etc. and there is Tap instead of click. The task is to remove the title attribute for example:

    if (innerWidth & lt; 1024 & amp; & amp; .... define here) {
    $ (. selector) .removeAttr ('title');

    In js or with jquery it doesn't matter.
    JavaScript Anonymous, Aug 22, 2019

  • 3 Answers
  • 0

  • 0
    <!DOCTYPE html> 
    <html lang="en">

    jQuery Detect Mobile Device

    if (window.matchMedia("(max-width: 767px)").matches)

    // The viewport is less than 768 pixels wide
    document.write("This is a mobile device.");
    } else {

    // The viewport is at least 768 pixels wide
    document.write("This is a tablet or desktop.");


  • 0
    Take User-Agent and identify it.

    https://github.com/serbanghita/Mobile-Detect/blob/. ..

    Help you. JSON split into mobiles / tablets, manufacturers, browsers

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!