JavaScript
Article
By Sam Deering

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.

--ADVERTISEMENT--

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

        // mobile code here
 
	}
});
Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account