Tribute Page JQuery Unexpected Token Error

Tribute Page JQuery Unexpected Token Error
0.0 0

#1

Hi all,

I’m attempting to put together my first tribute page and am having an issue targeting a class with a jquery function. I want to place the and

elements within a single white background similar to the example given. I’ve put these into a single div class named “picbed” but seem to get an “unexpected token ;” error on the jquery function. Is anyone able to advise on what this error is?

Thanks!


#2

You’ll need to post some of the code.


#3

Sorry, I thought I had but it doesn’t seem to have shown up.


#4

@JimmyT,
there is a lot to unpack in your code.

  • You have no JS code in your pen, so it is quite hard to understand to which JQuery function you are referring to

  • You have errors in your HTML markup -> <div class=col-md-6"> You are missing a double quotes symbol at the beginning

  • On a side note, you have a lot of divs and it would help readability if you could add comments as to what div tag is closing what div


#5

Thanks for the response, I tried a different way of working around the problem but the JQuery function I had previously included was:

<script>
 $(document).ready(function() {
$(."picbed").css("background-color", "white");    
  });
</script>


#6

“Unexpected token” almost always means a missing or misplaced semicolon or mismatched brackets/braces/parentheses/quotes .


#7

Just by looking at your code it seems you have misplaced the period of the class picbed. It should be inside the quotes and not outside.


#8

Thanks, I totally missed that. So I tried it with the period in the correct place and now I get the error message “Unexpected Token ILLEGAL”


#9

I just loaded the Codepen link above and I am not seeing any errors showing in the console.


#10

Hi Randell, I’ve been playing around with the code a bit so may have removed it when you opened the link. I’ve changed it now as was recommended above so it reads:

<script>
$(document).ready(function() {
$(".imgbed”).css(“background-color”, “white”);
});
</script>

It produces the same error I mentioned previously.


#11

If you put it in JS section just remove the script tag.
Edited:
I found that your double quote maybe the problem, I’m not sure that you use it from other Unicode or something
Hope this help :slightly_smiling_face: