JavaScript
Article

jQuery Detect Mobile Devices – iPhone iPod iPad

By Sam Deering

jQuery code snippet to detect if a user is viewing the website using a mobile device, specifically an iPhone iPod or iPad. You may also wish to detect the mobile browser type.

jQuery(document).ready(function($){
	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (agentID) {

        // mobile code here
 
	}
});
  • http://dskmedia.com Dencho

    Thanks, this came in very handy today.

  • http://crystalstudio.me Розробка сайтів Івано-Франківськ

    Thank you. This is exactly what I’ve been looking for

  • Baltazarz3

    worked perfect, thanks!

  • Solanio

    Bulshit !

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.