ASP.NET is a set of technologies in the Microsoft .NET Framework for building Web applications and XML Web services. C# is an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. JavaScript is a scripting language designed primarily for adding interactivity to Web pages and creating Web applications. jQuery is a lightweight, "write less, do more", JavaScript library. The purpose of jQuery is to make it much easier to use JavaScript on your website. AJAX - Asynchronous JavaScript and XML. AJAX is a technique for creating fast and dynamic web pages.

jQuery is not a language, but it is a well written JavaScript code. As quoted on official jQuery website, "it is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development."

In order to work with jQuery, you should be aware of the basics of JavaScript, HTML and CSS.
It was released in January 2006 at BarCamp NYC by John Resig.

Why jQuery?

jQuery is very compact and well written JavaScript code that increases the productivity of the developer by enabling them to achieve critical UI functionality by writing very small amount of code.
  • It helps to improve the performance of the application
  • It helps to develop most browser compatible web page
  • It helps to implement UI related critical functionality without writing hundreds of lines of codes
  • It is fast
  • It is extensible – jQuery can be extended to implement customized behavior
Other advantages of jQuery are:
  • No need to learn fresh new syntaxes to use jQuery, knowing simple JavaScript syntax is enough
  • Simple and cleaner code, no need to write several lines of codes to achieve complex functionality

Where to Download jQuery from?

jQuery JavaScript file can be downloaded from jQuery Official website.

How to Use jQuery?

jQuery usually comes as a single JavaScript file containing everything comes out of the box with jQuery. It can be included within a web page using the following mark-up:

To Load Local jQuery File

<script type="text/javascript" src="jQuery-1.4.1-min.js"></script> 
Ideally, this markup is kept in under <head></head> tag of your web page, however you are free to keep anywhere you want.

How to Execute jQuery Code?

There are two ways you may want to execute jQuery codes.

  1. As and when page loads, execute the jQuery code:

    <script language="javascript" type="text/javascript">
    $(function () {
    $("#div1").css("border", "2px solid green");
    });
    </script>
     
    or:

    <script language="javascript" type="text/javascript">
    $("#div1").css("border", "2px solid green");
    </script>
     
    The benefit of executing jQuery code in this way is that it doesn’t wait for the whole page to load completely, so in case you want the user to see the effects as soon as the corresponding elements are loaded, you can use this.
    However the disadvantage is that if the element on which jQuery has to execute has not loaded, then it will error out or you will not get the desired result; so while using this way of executing jQuery code, you will have to make sure that the element on which you want to work with jQuery is loaded first (you can place your jQuery code right after your HTML element).
  2. Execute jQuery only when the complete DOM objects (the complete page has been loaded). You will have to wrap your code in .ready function.

    <script language="javascript" type="text/javascript">
    $(document).ready(function () {
    $("#div1").css("border", "2px solid green");
    });
    </script>
     
    This is the better and safer way to execute jQuery. This makes sure that jQuery code will execute only if complete page has been loaded in the browser so you are rest assured that user will not see any undesired behavior on the page.
As a developer, the decision of where and how to write jQuery code lies on you. I prefer to use the second method as it ensures that my complete page is loaded in the browser and I am ready to play with any element available on the page

0 comments :

Post a Comment

Loading...