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.

	var deviceAgent = navigator.userAgent.toLowerCase();
	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
	if (agentID) {

        // mobile code here
  • Dencho

    Thanks, this came in very handy today.

  • Розробка сайтів Івано-Франківськ

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

  • Baltazarz3

    worked perfect, thanks!

  • Solanio

    Bulshit !



Because We Like You
Free Ebooks!

Grab SitePoint's top 10 web dev and design ebooks, completely free!

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