Aaron R
Aaron R

Reputation: 233

missing : after property ID

I don't understand what I'm doing wrong here... line 3 is reporting missing : after property ID

$(document).ready(function() {

    $('#imagegallery img').each(function({$(this).css({ width: '100%'});});

    $('#imagegallery').cycle({
        timeout: 0,
        fx: 'scrollHorz',
        width: '100%',
        height: 'auto',
        next: '.next',
        prev: '.prev' 
    });



    $("#imagegallery").touchwipe({
        wipeLeft: function() {
            $("#imagegallery").cycle("next");
        },
        wipeRight: function() {
            $("#imagegallery").cycle("prev");
        }
    });
});

Upvotes: 11

Views: 38493

Answers (5)

user
user

Reputation: 25728

This error also shows up when declaring a class method with function keyword (could have slipped in with copy-pasting):

class T {

    function name() {
        ...
    }
}

Should be just:

class T {

    name() {
        ...
    }
}

Upvotes: 0

user6809893
user6809893

Reputation: 1

The closing parenthesis missing is the each one

$('#imagegallery img').each(function({$(this).css({ width: '100%'});});)

Or

$('#imagegallery img').each(function({$(this).css({ width: '100%'});}));

Upvotes: -1

Vincent Fan
Vincent Fan

Reputation: 29

I also have an error show to definition of my function like below.

function test(a) {
   //do something;
}

My case to solve the problem by change it to:

test : function(a) {
   //do something;
}

The error is gone.

Upvotes: 2

cwallenpoole
cwallenpoole

Reputation: 82008

You're missing a close paren in

// $('#imagegallery img').each(function({$(this).css({ width: '100%'});}); 
// should be:
$('#imagegallery img').each(function(){$(this).css({ width: '100%'});});

Could that be it?

Upvotes: 0

user113716
user113716

Reputation: 322492

Problem is with this line:

$('#imagegallery img').each(function({$(this).css({ width: '100%'});});

should be:

    // missing ) --------------------v
$('#imagegallery img').each(function(){$(this).css({ width: '100%'});});

Although you can shorten it like this:

$('#imagegallery img').css({ width: '100%'});

Upvotes: 16

Related Questions