LearnjQuery Programming | Quick Tip

Andrew Chalkley
writes on November 16, 2012

jQuery is a JavaScript framework that makes it simple to add behavior to websites cross-browser using the same CSS selectors web developers are familiar with. This allows you to write less and do more

First, visit http://www.jquery.com and download the framework. You’ll also see what jQuery code looks like in action.

What you can do in one line of jQuery often amounts to several lines of JavaScript.

With over 80% of sites using jQuery, it has become the go-to framework for adding behavior and interactivity to your website.

Video Transcription

Andrew: Hi, I’m Andrew. In this Treehouse quick tip we’re talking about
jQuery and landing JavaScript. jQuery, a framework within JavaScript,
offers a simple way to add behavior to a website’s cross browser using the
same CSS selectors web developers are familar with. In other words, you can
write less and do more.

To get started with jQuery, visit jquery.com and straight off the bat you
can see what jQuery code looks like. If we right click and inspect the code
of this site, we can see the paragraph with the class “neat” and it’s
hidden with display “non”. Let’s see what happens when we hit “run code”.
As you can see, the paragraph has “oh my” [SP] added to its class
attribute, and the paragraph is shown. The $(“P.neat”) is jQuery selecting
the element you want to manipulate and add behavior to. The add class
method adds the class name you want to pass in as an argument. So, in this
case “Oh My” is added. Now, “neat” is still there, too, and the show method
with this speed of slow is passed in to show the hidden paragraph.

Notice that the methods are chained together, resulting in less lines of
code. What you can do in a line of jQuery, often amounts to lines and lines
of JavaScript. While jQuery weighs in around 30K, it’s worth the price of
an extra download instead of reinventing the wheel, implementing your own
cross browser framework. With over 80% of sites using jQuery, it’s become
the go-to framework when adding behavior and interactivity to websites. So,
what are you waiting for? Go download it now and try it out on your next

Announcer: If you’d like to see more advanced videos and tutorials like
this one, go to TeamTreehouse.com and start learning for free.

Leave a Reply

You must be logged in to post a comment.

Learn to code with Treehouse

Start your 7 day free trial today and get access to hundreds of video courses in web development, design and business!

Learn more