Syntax error, unrecognized expression: a[href*=#]:not([href=#]) #2885

Closed
DevelopOnline opened this Issue Jan 29, 2016 · 2 comments

Projects

None yet

3 participants

@DevelopOnline

I have used $('a[href*=#]:not([href=#])') selectior somewhere in my code like this:

$('a[href*=#]:not([href=#])').click(function () {
    console.log("Hello World");
})

It has worked without any issue with jQuery v2.1.4 and jQuery migrate v1.2.1, but I get this error message when I try to use jQuery 2.2.0 and jQuery migrate 1.3.0:

Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#])
jquery-2.2.0.js:1463:8

I'm using Firefox v44.0

Any Suggestion?!

@staabm
Contributor
staabm commented Jan 29, 2016

your selector is not valid. # is a special char and needs to be escaped like 'a[href*=\\#]:not([href=\\#])'

see https://api.jquery.com/category/selectors/

@dmethvin
Member

Yes, this is another duplicate of gh-2824.

@dmethvin dmethvin closed this Jan 29, 2016
@domProjects domProjects pushed a commit to domProjects/CI-AdminLTE that referenced this issue May 6, 2016
Emmanuel Campait BUG : report by FoxMiner #5
selector is not valid. # jQuery 2.2.0 >
jquery/jquery#2885
378249b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment