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

William Whitworth
William Whitworth
6,117 Points

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

Joe Manson
Joe Manson
11,817 Points

Take out the last )

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

and put it at the very end after the last }

James Barnett
James Barnett
39,199 Points

Don't forget to add a semicolon at the end

Kevin Korte
Kevin Korte
28,148 Points

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.

Max Hallinan
Max Hallinan
7,614 Points

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.