I would like to disable part of my jQuery script for mobile devices, heres the code I\'d like to disable:
$(\'#inner-slide1\').click(function(e) {
e.prev
You may try
MatchMedia.js
There is details on https://github.com/paulirish/matchMedia.js
You can load the plugins according to the certain viewport size.
Using the code from http://detectmobilebrowsers.com/ use the JS code to detect if mobile - very comprehensive detection... will require a bit of modification as their function will redirect... but should be easy to do :)
Also here is another good answer from here: disable script for mobiles
You're repeating a function 5 times when you need only do it once if you just give those elements a class (I'm going for .inner-slide):
var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false;
$('.inner-slide').click(function(e) {
if(!isMobile) {
e.preventDefault();
dataslide = $(this).attr('data-slide');
goToByScroll(dataslide);
}
});
The if statement will only result to true on a mobile device (Android,webOS,iPhone,iPad,iPod,Blackberry)
And please note that
$(this).attr('data-slide');
Can also be written as:
$(this).data('slide');