Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is jsfiddle giving me the error "SyntaxError: Unexpected token :"?

I'm using structured javascript code and it works fine on my computer. But when I add it to jsFiddle, it gives me the followinge error:

SyntaxError: Unexpected token :

My code looks like this:

var StentGallery = {
    gallery: null,

    init : function(){
            this.gallery = jQuery('#gallery-list-ui');
            this.resizeImage();
        }
    }
    (...)
}

Does anyone know why this is not working in jsFiddle?
See my fiddle here: https://jsfiddle.net/smyhbckx/

like image 850
Steven Avatar asked Feb 08 '23 08:02

Steven


1 Answers

There's a syntax error in your code:

var StentGallery = {
    gallery: null,

    init : function(){
           this.gallery = jQuery('#gallery-list-ui');
           this.resizeImage();
           } // <----- this is prematurely closing your object
    }, 

    resizeImage: function(){
    ...

To fix this, simply remove that bracket:

var StentGallery = {
    gallery: null,

    init : function(){
           this.gallery = jQuery('#gallery-list-ui');
           this.resizeImage();
    },

    resizeImage: function(){
    ...
like image 89
Nick Zuber Avatar answered Feb 11 '23 00:02

Nick Zuber