Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Err.. This is frustrating, why is this giving me a semantic error?

I'm trying to run this script and I keep getting Semantic issue, expected token '{' - with the first line highlighted.

jQuery(document).ready(function($)) {
    $('.bxslider').bxSlider({
                        mode: 'horizontal',
                        captions: false,
                        auto: true,
                        randomStart: true,
                        useCSS: false,
                        pager: false,
                        autoHover: true,
                        control: false,
                        nextSelector: '.slider-next',
                        prevSelector: '.slider-prev',
                        nextText: '?',
                        prevText: '?'
                        });
}

Any help would be great!

3 Answers

Take out the last )

jQuery(document).ready(function($))<< {

and put it at the very end after the last }

Don't forget to add a semicolon at the end

Why is there a $ being passed as a function argument? Have you tried it without? Usually on those you are not passing arguments to the function.

Here is an article by Chris Coyier that involves an explanation of $ being passed as an argument. He explains this much better than I can. Plugins often use this technique to avoid conflicts with any other JS libraries a developer may be using on a project. I'm guessing from the above snippet that the code was pulled from a carousel plugin.

Got it to work, thanks!