13 Mar, 2009
Posted by: Mahbub In: Methods
One of the best thing about jQuery is it’s chain ability for almost all it’s methods. If “chain ability” sounds hebrew, here’s a little explanation what it is.

Let’s say you have a <div id=”myDiv”>Lorem Ipsum </div>
And you need to do the following
- Change the height to 150px
- Change the opacity to 0.8
- Add a class called “pClass”
- And set the text inside the div like “We are the world”
So, what would you do in normal circumstances? You write four lines of code. Like if you use jQuery in conventional way you’d probably write
1
2
3
4
| $("#myDiv").css("height","150px");
$("#myDiv").fadeTo(500,0.8);
$("#myDiv").addClass("pClass");
$("#myDiv").text("We are the world"); |
But if we use method chaininig we’d simply write
$("#myDiv").css("height","150px").fadeTo(500,0.8).addClass("pClass").text("We are the world");
Looks messy ? I don’t think so. It’s readable unless you put quite a lot of methods to an object which is very unlikely. So that is chaining.
Behind the screens , chaining is simply done by returning the object itselft after applying the method. It’s quite like how we use methods in Javascript Object like
var myString="Lorem Ipsum Dolor";
pString= myString.toLowerCase().substring(0,5);
And this is a gift when we have options to do things like that. Who wants to write more code when there’re ways to make it short ? At least I don’t. So almost all of the methods
in jQuery has this chainability. All the methods that chain, returns the whole jQuery object itself so that more methods can be applied to it.
You can see the above code running here.
11 Feb, 2009
Posted by: Mahbub In: misc
Well, there have been many articles on the WWW which would suffice “Why jQuery is the choice”. To me, it’s just precise, well structured, high learning curve and easy to use. When I was in the beginning of my Undergrad back in 1999, there was no library to deal with the cross browser issues (Netscape used to make life miserable for javascript programmers). So we had to write longer scripts for a specific purpose and handle the cross browser issues. Thomas Brattli at dhtmlcentral gave some pretty good scripts on menus and some libraries which we used to implement. But above all there was no such good library which could do magics, a library that you can extend easily the way you want, something meets the real programming standard. The journey to making javascript framework began much early. There are quite a number of libraries that started namely mochikit, prototype, mootools, dojo etc. But you should use jQuery for :
1. Very Lightweight, weighs less than 20k when minimized and gzipped.
2. High learning curve.
3. Super chainability. Almost Every jQuery method returns the Jquery object which lets you put methods in tails one after another. like $(“#div_one”).css(“border”,”1px solid #000″).fadeTo(300,0.5).slideUp(300);
4. Can be used with other libraries such as mootools using noconflict().
5. Easy to write plugins.
6. Code becomes short, sweet and easy to understand.
7. You don’t have to be a Javascript geek top write jQuery codes.
8. IMPORTANT : Vast community support and contributions.
9. Used by major open source applications like Drupal, Wordpress.
10. Microsoft chose jQuery to use it with their applications. (may be a good point to some MS fans
)
11. Very easy to play with DOM. Lot of built in methods integrated. DOM selectors are very untuitive.
12. Supports XPATH selectors.
13. VERY VERY easy built-in AJAX utilities. (leave me an email if anyone needs to know how easy this is).
Ok.. enough for now. The list could go quite long.
More to come soon.
30 Aug, 2008
Posted by: Mahbub In: misc
So after all jQuery changed their site’s look and feel. Earlier it was kind of geek interface and somewhat boring. The new look is much professional.

At the day of the new look launch, there was a tag-line saying “Become a Javascript Rock Star” with a cartoon. But community users seemed to have disliked it heavily and after more and more negative comments Read the rest of this entry »
I assume that we know what jQuery is. Well to brush it up, “jQuery is a javascript library that makes our life easier”
. I like to define in that way. Ok, now in this post, I’m gonna show you how to get things started for jQuery. As you can read this blog, it’s obvious that you have an Internet connection and of course you’re using some browser. So let’s just try one piece of code before making the post lengthy. Before that let’s see what we need for that
- jQuery Library (download from http://jqueryjs.googlecode.com/files/jquery-1.2.6.js) This is the current release when I’m writing the post.
- A modern browser (IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+) with javascript enabled.
- And a text editor (my Fav is notepad++)
I suppose we all know how does a basic html page look like. We’d just run a simple piece of code adding jQuery library
Now, just copy and paste the above code and save it calling “jquery-test.html”. Read the rest of this entry »
20 Aug, 2008
Posted by: Mahbub In: misc
jQuery Magic is intended to show some tutorials, snippets or tips and tricks that is not generally available with the official jQuery site even if in the plugins site. We call those magics because
jQuery itself is full of magics, things you never thought possible with some tiny piece of codes.
I’ll try to show the tips and trick for the beginner, intermediate and advanced levels. I will also welcome interested authors who want to contribute to this site with their tips and tricks.
Recent Comments