I'm having trouble combining a few jQuery functions. Any help is appreciated. Each script works individually but when I try to combine them together only one works (the iOS hover) and I'm not sure why. I'm doing some workaround for issues only on iOS devices. I would like to include the second function in the first which I can't seem to do.
First function works fine as long as second function is commented out:
$(document).ready (function(){
/**iOS phone number fix for text color**/
$(".phone #phonenumber").remove();
$(".phone").append("<div id='phonenumber2'><span class='callustext'>Call us : (800) 000-0000</span></div>");
/**iPad fixes for subnav styling at 768px**/
if(screen.width == 768){
$("#innerpage .mainnav ul li ul").css("background","transparent");
$("#innerpage .mainnav ul li.mainnavlink a:hover").css("color","#91b39e");
$("#innerpage .mainnav ul li.mainnavlinkactive a:hover").css("color","#91b39e");
$("#innerpage .mainnav ul li.mainnavlink ul li a").css("border-bottom","none");
$("#innerpage .mainnav ul li.mainnavlinkactive ul li a").css("border-bottom","none");
$("#innerpage .mainnav ul li.mainnavlink ul li a:link").css("text-transform","none").css("color","#d7d7d7");
}
});
Second function works fine when first is commented out:
/**iOS Hover fix**/
$(document).ready(function() {
if(navigator.platform == "iPad") {
$("a").each(function() {
var onClick; // this will be a function
var firstClick = function() {
onClick = secondClick;
return false;
};
var secondClick = function() {
onClick = firstClick;
return true;
};
onClick = firstClick;
$(this).click(function() {
return onClick();
});
});
}
});
Reference: iOS automatic hover fix?