check if browser is chrome mobile 1

check if browser is chrome mobile

$(document).ready(function(){
    var ua = navigator.userAgent;

    if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua))
       $('a.mobile-other').show();

    else if(/Chrome/i.test(ua))
       $('a.chrome').show();

    else
       $('a.desktop-other').show();
});

Here is what the above code is Doing:
1. It’s checking the user agent of the browser.
2. If the user agent is a mobile device, it shows the link with the class mobile-other.
3. If the user agent is Chrome, it shows the link with the class chrome.
4. If the user agent is neither a mobile device nor Chrome, it shows the link with the class desktop-other.

Similar Posts