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

Can anyone explain to me what the '$' mean in a javascript file?

So I'm using flexslider and I have something like this:

$('#peopleslider').flexslider({ animation: "slide", controlNav: false, animationLoop: false, slideshow: false,

    prevText: "<i class='fa fa-caret-left fa-lg'></i>",
    nextText: "<i class='fa fa-caret-right fa-lg'></i>",


    itemWidth: 175,
    itemMargin: 0,
    minItems: 1,
    maxItems: 5,

    asNavFor: '.flex-active-slide'

}); 

simpler form this: $().flexslider({ });

Sorry the js is no being read correctly.

2 Answers

Gabriel Ward
Gabriel Ward
20,222 Points

Hi Victor,

the $ sign is another way of writing jQuery, so you could have

jQuery('#peopleslider').flexslider({ animation: "slide", controlNav: false, animationLoop: false, slideshow: false,

instead of

$('#peopleslider').flexslider({ animation: "slide", controlNav: false, animationLoop: false, slideshow: false,

It is a place holder for the function you are writing out, and when you have it in place, the jQuery library is called on your function. So in this case the HTML element with id of "peopleslider" will be modified using the jQuery you have in your function.

I hope that helps your understanding.

Stephen O'Connor
Stephen O'Connor
22,291 Points

It's not the technical term but I think of it as 'look for' or 'search for' on the page, so $('.footer') would essentially mean jQuery would 'look for' the element that has the class footer and then do something with it. The more technical term can be found here. Hope this helps.