I currently am using a script that executes a fade effect when mousing over icons (It fades them from color to black and white). I’m having issues with it not working properly on an iPad or iPhone because of the hover event.
Is there any way to wrap the following in a conditional that will exclude an iPad, iPhone and possibly even a droid device from running it?
<script>
$(document).ready(function() {
$("ul.gallery li").hover(function() { //On hover...
$(this).siblings().each(function () {
var thumbOver = $(this).find("img").attr("src"); //Get image url and assign it to 'thumbOver'
//Set a background image(thumbOver) on the <a> tag
$(this).find("a.thumb").css({'background' : 'url(' + thumbOver + ') no-repeat center bottom'});
//Fade the image to 0
$(this).find("span").stop(false,false).fadeTo('normal', 0 , function() {
$(this).hide() //Hide the image after fade
});
});
} ,
function() { //on hover out...
$(this).siblings().each(function () {
//Fade the image to 1
$(this).find("span").stop(false,false).fadeTo('normal', 1).show();
});
});
});
</script>
Thank You
you can check for ‘iPad’ using
navigator.platform:similarly, you can check for other iDevices using an object literal and the
inoperator:to keep your code from running under these conditions, you can keep your setup logic above in a named function and execute it conditionally on DOM-ready, such as:
to be honest, i’ve never done android detection, but there should be a similar method.
hope that helps! cheers.