rob cherny.com

About

My name is Rob Cherny and I'm a professional Web Developer with 16 years of experience creating Web sites and Web-based applications. This site is where I write about my work, and random other things...

Learn More

Loading...

Close Tab

Web Development

Using jQuery

So since first reading about it, I’ve been enamored with the jQuery JavaScript library. It’s simple chainable methods and the fact that both CSS selectors and XPath were valid ways of finding elements all appealed to me. This CSS selector support is common sense, and it’s never quite made sense to me that we’ve had to code a million versions of document.getElementsByClassName() or document.getElementsBySelector() for instance. Some things should just be built in.

Some of the other great things about it are that it comes packed for small file size and you can choose your base packages based on what types of functionality you want. So, you’re not stuck with some huge library that you are only using a portion of. I’ve alluded to this before, but I’m a huge supporter of the right tool for the right job. Just as I opted against using my Ajax script on this site by weighing pros and cons, remember to look at the big picture when making your choice. But that’s another article.

It’s just easy. Just like Prototype, it comes with it’s very own "$()" function, but you can do a lot more with it:

  1. $("#nav-globals li:last-child").addClass("last");

That adds a class of ”.last” to a selector that IE6 and below doesn’t support. Easy. Looks just like a getElementBySelector() script? Well, with any selector you can bind events, hide and show content, and more -- including a new Ajax plugin. Check out the jQuery examples.

jQuery Event Showdown

At any rate, over at the jQuery blog, John Resig has posted another example of why it’s so great, stacking up an example of binding some events to some selectors as compared to Prototype and Behaviour and a few others. Much less code all over. And less is more.

Check it out. jQuery rocks.

May 9, 01:20 AM in Web Development (filed under ChernyCom, JavaScript)

commenting closed for this article

In This Section