Mark's Stuff

My Foray Into Weblogging. Using this to store interesting items for later review.

Friday, October 17, 2008

What is jQuery?

I first heard of jQuery when Microsoft (actually, Scott Guthrie, the Microsoft VP for Developer Division) announced support for it (see the link below). Then, the .Net Developer User Group had a session on it last week. This is something simple, easy to implement and add to our toolkit, and can save a ton of time adding desirable features to our websites.

If you have not heard about jQuery before:

  • JavaScript library, just link a javascript file to your web page to enable it.
    e.g. : <script type="text/javascript" src="../jquery.min.js"></script>
  • a lightweight JavaScript library, only 15kb in size.
  • Licensed under GPL or MIT (any and all use is free, commercial or otherwise permitted)
  • supported browsers: Firefox 1.5+, Internet Explorer 6+, Safari 2.0.2+, Opera 9+

Good beginning description of it from Scott Guthrie’s blog (http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx):

A big part of the appeal of jQuery is that it allows you to elegantly (and efficiently) find and manipulate HTML elements with minimum lines of code.  jQuery supports this via a nice "selector" API that allows developers to query for HTML elements, and then apply "commands" to them.  One of the characteristics of jQuery commands is that they can be "chained" together - so that the result of one command can feed into another.  jQuery also includes a built-in set of animation APIs that can be used as commands.  The combination allows you to do some really cool things with only a few keystrokes.

For example, the below JavaScript uses jQuery to find all <div> elements within a page that have a CSS class of "product", and then animate them to slowly disappear:

clip_image002

As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of "datagrid1", then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of "even" - which could be used to alternate the background color of each row:

clip_image004

Microsoft will be bundling and supporting jQuery from now on

Again from Scott Guthrie’s blog:

  • “Microsoft will be shipping jQuery with Visual Studio going forward”
  • “We will distribute the jQuery JavaScript library as-is, and will not be forking or changing the source from the main jQuery branch.  The files will continue to use and ship under the existing jQuery MIT license.”
  • “will also distribute intellisense-annotated versions that provide great Visual Studio intellisense and help-integration at design-time.”
  • “add the jQuery library by default to all new projects.”
  • “We will also extend Microsoft product support to jQuery beginning later this year, which will enable developers and enterprises to call and open jQuery support cases 24x7 with Microsoft PSS.”
  • “Going forward we'll use jQuery as one of the libraries used to implement higher-level controls in the ASP.NET AJAX Control Toolkit.”

Here are some links on jQuery:

· http://jquery.com/

· Download: http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js&downloadBtn=%3CSPAN%3EDownload%3C%2FSPAN%3E

· Documentation: http://docs.jquery.com/Main_Page

· Tutorials: http://docs.jquery.com/Tutorials

· Scott Hanselmann’s tutorial using jQuery in Visual Studio and Ajax and ADO.Net Data Services: http://www.hanselman.com/blog/jQuerytoshipwithASPNETMVCandVisualStudio.aspx

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home