JQuery unrecognized expression [href=#undefined]

I just upgraded wordpress on my site to v4.5.1 however since doing this some functionality on my site has broken….

When I view the console I see this message:

Read More
Uncaught Error: Syntax error, unrecognized expression: [href=#undefined]

I’m completely at a loss as to where to look to fix this issue… would anyone have any idea what might be causing this issue? I’ve checked and I’m running jQuery 1.12.3 as this comes packed with WordPress.

Upon further inspection I think the error is being thrown from within the below function… I can’t seem to fix it though, any ideas?

  currentScrollIndication: function () {
    var e = 0;
    j.hasClass("sticky-header-enabled") && (e = jQuery(".header-wrap").height());
    var t = jQuery(".blank_spacer:in-viewport:first").attr("id"), 
        a = jQuery("#main-navigation .menu li a"), 
        i = a.filter("[href=#" + t + "]");
    a.parent().removeClass("current-scroll-item"), 
    i.length > 0 && !i.hasClass(".current-scroll-item") && (a.parent().removeClass("current-scroll-item"), 
    i.parent().addClass("current-scroll-item"))
}

Related posts

1 comment

  1. Since #undefined is not a valid CSS identifier, you cannot use it bare like that.

    Instead, you need [href='#undefined'], which means your JS code is:

    i = a.filter("[href='#"+t+"']");
    

Comments are closed.