$(window).scroll(function() { var scrolls = $(this).scrollTop(); $(".header").each(function(){ //类名为“header”的块级元素 var height = $(this).height(); if($(this).position().top + height-60> scrolls){ var _index = $(".header").index($(this)); $(".header").addClass("header-color");//添加class属性 return false; } });});
ReferenceError: $ is not defined -> $(window)这个该如何做
解决方案
没引入jquery