stavarotti
stavarotti

Reputation: 582

Unrecognized expression jquery attribute selector

I get the following error:

Uncaught Syntax error, unrecognized expression: [src$=="copyright.gif"] k.errorjquery_1_6_2_min.js:17 k.filterjquery_1_6_2_min.js:17 kjquery_1_6_2_min.js:17 c.querySelectorAll.kjquery_1_6_2_min.js:17 f.fn.extend.findjquery_1_6_2_min.js:17 e.fn.e.initjquery_1_6_2_min.js:16 ejquery_1_6_2_min.js:16 (anonymous function)

when executing the following script:

var copyright = $('img[src$="copyright.gif"]').attr('src');

using the tag below:

<img border='0' src='/resources/copyright.gif' alt='copyright' />

Any ideas why this is happening? I am using 1.6.2.min.js

Upvotes: 0

Views: 1754

Answers (2)

Alistair Laing
Alistair Laing

Reputation: 973

That works oh jsfiddle http://jsfiddle.net/vw6TS/2/. Are you using your own local copy of jquery if so make sure its a complete file and not corrupted.

Upvotes: -1

aziz punjani
aziz punjani

Reputation: 25776

It's happening because in the code you're actually doing

$('img[src$=="copyright.gif"]').attr('src');

instead of what you posted, which is this

var copyright = $('img[src$="copyright.gif"]').attr('src');

Upvotes: 3

Related Questions