0

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

4
  • 3
    in the error its saying that you have src$==" instead of src$=" Commented Oct 12, 2011 at 19:59
  • 1
    Can't reproduce: jsfiddle.net/nrabinowitz/3ngFE Commented Oct 12, 2011 at 19:59
  • $("img[src$='copyright.gif']") notice the quotes and double quotes Commented Oct 12, 2011 at 20:01
  • @Laurence. That is the error I get when I use the code listed in the question section. Perhaps the jquery source that I have is corrupted. I will re-download and try again. Commented Oct 12, 2011 at 20:22

2 Answers 2

3

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');
Sign up to request clarification or add additional context in comments.

4 Comments

Don't assume, i put $('img[src$=="copyright.gif"]').attr('src'); into the console and got the same error.
yes but I commented because I wanted to make sure that the op's question wasnt a typo or if he was getting this error with the code he posted.
Gave you a +1 because it most like for now is the correct answer and I wouldnt want to double up on the same question
Perhaps my local copy is corrupted. A straight copy and paste of what you have posted yields the same error. I downloaded jquery source about 4 hours ago. I will download the source and try again.
-1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.