Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Tony Brackins26,688 Points
$ in JQuery
$ = JQuery
$ (".warning") = document.getElementsByClassName("warning")
How does JS know whether to choose the document or JQuery? Or is JQuery the same as document?
morgan seguraCourses Plus Student 6,934 Points
Also, you don't have to use the dollar sign, jQuery('.warning') is the basic usage, but the dollar sign is easier and common practice.
Daniel Botta17,956 Points
$ (".warning") and document.getElementsByClassName("warning") are the same thing. You will get the same result from both of them.
$ (".warning") is really just jQuery's more simplified shorthand version of document.getElementsByClassName("warning").
I hope this helps answer your question!
$ is the short hand for jQuery. You can use the $ to access jQuery's methods. By using $("#someElement") You are using jQuery to select an element on the page.
Maybe this will help?