HTML and CSS Reference
In-Depth Information
jQuery Is a JavaScript Library
As an ASP.NET developer, you must have used JavaScript in one way or the other while developing ASP.NET
web sites. Without a doubt, plain JavaScript helps you code rich, interactive, more responsive web pages;
but you often need to write too much code. For example, if you wish to write a client script that shows a
fancy pop-up menu complete with animation effects using plain JavaScript, it's a time-consuming task.
To simplify your client-side scripting and make you more productive, several JavaScript libraries are
available, and jQuery is one of them. There are others, such as MooTools, Prototype, and Dojo. The fact
that Microsoft uses jQuery extensively in ASP.NET projects clearly indicates jQuery's popularity and
Microsoft's intention to support it in ASP.NET. As you would expect, jQuery is cross-browser and supports
all leading browsers including Internet Explorer, Firefox, Chrome, Opera, and Safari.
jQuery Is Fast and Concise
jQuery is highly optimized library. Moreover, it's compact. The production version of jQuery 1.7.2 is just
32KB, and the development version is 247KB. This compactness means less data to be downloaded on the
client side without compromising stunning UI effects.
jQuery Simplifies Traversing HTML Documents,
Event Handling, Animation, and Ajax Interactions
jQuery simplifies HTML DOM navigation and manipulation considerably. It offers many ways to
transverse DOM trees and parent-child elements. Most JavaScript functionality goes in client-side event
handlers. jQuery is handy when it comes to event handling because it's easy to wire event handlers and
process the events. jQuery also allows you to make Ajax calls to ASP.NET web services, web methods,
Windows Communication Foundation (WCF) services, and MVC controller actions.
jQuery Is Designed to Change the Way You Write JavaScript
jQuery dramatically changes the way you write JavaScript code. If you've never used jQuery before, initially
you may find its syntax a bit odd; but once you get hang of it, you'll probably never look at any other
library (or at least the traditional way of writing JavaScript). For example, a common JavaScript file
contains several functions, and you call them individually whenever required. With jQuery, the chain of
operations makes your code compact. jQuery lets you chain methods together so the output from one
method is automatically processed by the next method in the chain. This makes it easier to invoke
multiple methods on the same output.
Downloading and Referring to jQuery
Before you use any of jQuery's features and constructs, you need to refer to it in your Web Forms or MVC
views. You can refer to the jQuery library in two ways:
• Refer to a local copy of the jQuery library.
• Refer to the jQuery library from Microsoft's Ajax Content Delivery Network (CDN).
To refer to a local copy of the jQuery library, you should first download it from jQuery official web site
( ) to your local machine. If you create a new ASP.NET MVC project, the jQuery library is
automatically placed in the Scripts folder (Figure 2-1). Of course, if you wish to use the latest version of
the jQuery library, you need to download it separately.
Search WWH ::

Custom Search