Javascript 带有菜单项链接锚点的jQuery错误:语法错误,无法识别的表达式
此代码引发语法错误,无法识别的表达式:在wordpress中,我有一个带有自定义url的菜单项,其锚点如下: 这是一个菜单中的代码,使用jQuery设置动画,导致错误的行是Javascript 带有菜单项链接锚点的jQuery错误:语法错误,无法识别的表达式,javascript,jquery,Javascript,Jquery,此代码引发语法错误,无法识别的表达式:在wordpress中,我有一个带有自定义url的菜单项,其锚点如下: 这是一个菜单中的代码,使用jQuery设置动画,导致错误的行是 if(jQuery(id).isOnScreen()){ 任何提示都会被欣赏。请提供一个完整的代码。我怎么做?这是一个来自Wordpress模板的js。我可以发布所有的js代码,但我不知道如何将所有的css和html放在JSFIDLE中。请提供一个完整的代码。我怎么做?这是一个来自Wordpress模板的js。我可以发布所有
if(jQuery(id).isOnScreen()){
任何提示都会被欣赏。请提供一个完整的代码。我怎么做?这是一个来自Wordpress模板的js。我可以发布所有的js代码,但我不知道如何将所有的css和html放在JSFIDLE中。请提供一个完整的代码。我怎么做?这是一个来自Wordpress模板的js。我可以发布所有的js代码,但我不知道我不知道如何将所有css和html放在JSFIDLE中。。
jQuery(document).ready(function() {
jQuery(".pagenav.home .menu > li:first-child a").addClass('important_color');
if (jQuery(".menu-fixedmenu").length) {
jQuery(".menu-fixedmenu.home .menu a").each(function() {
var id = jQuery(this).attr('href');
if (id.search("#") != -1) {
jQuery(window).scroll(function() {
if (jQuery(id).isOnScreen()) {
jQuery(id + ' h2').removeClass('fadeInDown');
jQuery(id + ' h2').addClass('animated fadeInUp');
var newid = id.split("#");
if (document.getElementById(newid[1]).getBoundingClientRect().top < 250) {
jQuery(".fixedmenu .menu > li a[href='" + id + "']").addClass('important_color');
} else {
jQuery(".fixedmenu .menu > li a[href='" + id + "']").removeClass('important_color');
}
} else {
if (id != jQuery(".menu > li:first-child a").attr('href'))
jQuery(".fixedmenu .menu > li a[href='" + id + "']").removeClass('important_color');
if (jQuery(this).scrollTop() > 700)
jQuery(".menu-fixedmenu.home .menu > li:first-child a").removeClass('important_color');
else
jQuery(".menu-fixedmenu.home .menu > li:first-child a").addClass('important_color');
jQuery(id + ' h2').removeClass('fadeInUp');
jQuery(id + ' h2').addClass('animated fadeInDown');
}
});
}
});
}
});
jQuery.fn.isOnScreen = function(){
var win = jQuery(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
bounds.bottom = bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};