jQuery Programming | Quick Tip

quickTips_blogHeaders_JavaScript

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
project.

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

Free Workshops

Watch one of our expert, full-length teaching videos. Choose from either HTML, CSS or Wordpress.

Start learning

Andrew Chalkley

I'm an alien, I'm a legal alien, I'm an Englishman in Portland. All of my professional life I've worked with computers online. I'm a polyglot programmer and like using the right tools for the job. In my spare time I enjoy spending time with my young family and when I get chance, sticking opponents in Halo 4. You can find me in most places @chalkers.

Comments

Comments are closed.