我尝试将jquery库从1.11.2 (<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>)
升级到2.1.0 (<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>)
,并且正如我所做的那样,我的jquery函数只是停止在on-load上运行而且只在重新调整大小时。
为什么?是(窗口)。现在已经过时了?请有人指出我需要更改/更新的内容吗?
以下是三个功能:
//Fullscreen
$(window).on("ready resize", function() {
if (window.innerWidth > 1024) {
var newHeight = $("html").height() + "px";
$(".fullscreen").css("height", newHeight);
} else {
var newHeight = $("html").height() + "px";
$(".fullscreen").css("height", newHeight);
}
});
//Header & page stubilizer
$(window).on("ready resize", function() {
if (window.innerWidth > 1024) {
if (!$('#header').hasClass("header-fixed")) {
var pageTop = $("#header").outerHeight() + "px";
$("#page .topSection").css({
"padding-top" : pageTop,
"margin-top" : "-" + pageTop
});
}
if ($('#header').hasClass("header-fixed")) {
var pageTop = $("#header").outerHeight() + "px";
$("#page .topSection").css({
"padding-top" : pageTop,
"margin-top" : 0
});
}
} else {
var pageTop = $("#secondHeader").outerHeight() + "px";
$("#page .topSection").css({
"padding-top" : pageTop,
"margin-top" : 0
});
}
});
//Off-Canvas Menu
$(function offCanvasMenu() {
var $page = $('#page, #header'),
$mainMenu = $('#mainMenu'),
$menuSwitch = $('#header').find('.mainMenu-switch'),
$menuSwitchIcon = $('#header').find('.mainMenu-switch-icon');
$menuSwitch.on('touchstart click', function(e) {
e.preventDefault();
$page.toggleClass("pageOpen");
$mainMenu.toggleClass("mainMenuOpen");
$menuSwitchIcon.toggleClass("mainMenu-switch-active");
});
$('#page').on('touchstart click', function() {
$page.removeClass("pageOpen");
$mainMenu.removeClass('mainMenuOpen');
$menuSwitchIcon.removeClass("mainMenu-switch-active");
});
});
//Toggle Optional Inputs Group
$(".input-toggle > div").hide();
$(".input-toggle a > span:last-of-type").hide();
$(".input-toggle a").click(function() {
$(this).next("div").slideToggle("fast");
var spans = $("span", this);
spans.not(spans.filter(":visible").hide()).show();
});
//Responsive Side/Side System
$(window).on("ready resize", function() {
if (window.innerWidth < 600) {
$(".side-by-side.right-side .gridB").each(function() {
$(this).insertAfter($(this).parent().find('.gridA'));
});
} else {
$(".side-by-side.right-side .gridB").each(function() {
$(this).insertBefore($(this).parent().find('.gridA'));
});
}
});
//Sideshow
$(function() {
$('.slideShow .slide:gt(0)').hide();
setInterval(function() {
$('.slideShow .slide:first-child').fadeOut().next('.slide').fadeIn().end().appendTo('.slideShow');
}, 3000);
});