• Page 1 of 1
  • 1
uCause Community » Trash & Archives » Other » jQuery (Must Read)
jQuery
SirDarknight(Tonmoy)Date: Friday, 2011-07-15, 8:30 PM | Message # 1
Member
Group: Senior Members
Messages: 894
Awards: 10
Reputation: 15
Status: :-(
jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig. Used by over 43% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today.

jQuery is free, open source software, dual-licensed under the MIT License and the GNU General Public License, Version 2. jQuery's syntax is designed to make it easier to navigate a document, select DOM elements, create animations, handle events, and develop Ajax applications. jQuery also provides capabilities for developers to create plug-ins on top of the JavaScript library. This enables developers to create abstractions for low-level interaction and animation, advanced effects and high-level, theme-able widgets. The modular approach to the jQuery framework allows the creation of powerful and dynamic web pages and web applications.

Microsoft and Nokia have announced plans to bundle jQuery on their platforms, Microsoft is adopting it initially within Visual Studio for use within Microsoft's ASP.NET AJAX framework and ASP.NET MVC Framework while Nokia has integrated it into their Web Run-Time widget development platform. jQuery has also been used in MediaWiki since version 1.16.

Features

jQuery contains the following features:

  • DOM element selections using the cross-browser open source selector engine Sizzle, a spin-off out of the jQuery project
  • DOM traversal and modification (including support for CSS 1-3)
  • Events
  • CSS manipulation
  • Effects and animations
  • Ajax
  • Extensibility through plug-ins
  • Utilities - such as browser version and the each function.
  • Cross-browser support

    Including the library

    The jQuery library is a single JavaScript file, containing all of its common DOM, event, effects, and Ajax functions. It can be included within a web page by linking to a local copy, or to one of the many copies available from public servers (such as Google or Microsoft CDN).

    Code
    <script type="text/javascript" src="jquery.js"></script>


    The most popular and basic way to introduce a jQuery function is to use the .ready() function.

    Code
    $(document).ready(function() {
    // jquery goes here
    });


    or the shortcut

    Code
    $(function() {
    // jquery goes here
    });


    Usage styles

    jQuery has two usage styles:

    via the $ function, which is a factory method for the jQuery object. These functions, often called commands, are chainable; they all return jQuery objects
    via $.-prefixed functions. These are utility functions which do not work on the jQuery object per se.

    Typically, access to and manipulation of multiple DOM nodes begins with the $ function being called with a CSS selector string, which results in a jQuery object referencing matching elements in the HTML page. This node set can be manipulated by calling instance methods on the jQuery object, or on the nodes themselves. For example:

    Code
    $("div.test").add("p.quote").addClass("blue").slideDown("slow");


    This line finds the union of all div tags with class attribute test and all p tags with CSS class attribute quote, adds the class attribute blue to each matched element, and then slides them down with an animation. The $ and add functions affect the matched set, while the addClass and slideDown affect the referenced nodes.

    The following script automatically checks whether the jQuery file is included. If not, it appends a jquery reference to the head section

    Code
    if(!(window.jQuery && window.jQuery.fn.jquery == '1.6.1')) {
       var s = document.createElement('script');
       s.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js');
       s.setAttribute('type', 'text/javascript');
       document.getElementsByTagName('head')[0].appendChild(s);
    }

    The methods prefixed with $. are convenience methods or affect global properties and behaviour. For example, the following is an example of the map function called each in jQuery:

    Code
    $.each([1,2,3], function(){
       document.write(this + 1);
    });

    This writes the number 234 to the document.

    It is possible to perform browser-independent Ajax queries using $.ajax and associated methods to load and manipulate remote data.

    Code
    $.ajax({
       type: "POST",
       url: "example.php",
       data: "name=John&location=Boston",
       success: function(msg){
         alert( "Data Saved: " + msg );
       }
    });

    This example posts the data name=John and location=Boston to example.php on the server. When this request finishes successfully, the success function is called to alert the user.

    jQuery plug-ins

    Because of jQuery's architecture, other developers can use its constructs to create plug-in code to extend its functionality. Currently there are thousands of jQuery plug-ins available on the web that cover a wide range of functionality such as Ajax helpers, webservices, datagrids, dynamic lists, XML and XSLT tools, drag and drop, events, cookie handling, modal windows, even a jQuery-based Commodore 64 emulator.

    An important source of jQuery plug-ins is the Plugins sub-domain of the jQuery Project website. There are alternative plug-in search engines that take more specialist approaches, such as only listing plug-ins that meet certain criteria (e.g. those that have a public code repository). The tutorials page on the jQuery site has a list of links to jQuery plug-in tutorials under the "Plugin development" section.

    Etymology

    The use of the name jQuery is somewhat fanciful, as the library has little to do with queries. Shortly after its release in January 2006, author John Resig stated, "I was, originally, going to use JSelect, but all the domain names were taken already."

    Please Give Me A Award or + Rep If My Post Helps You

    Please Give Me A Award or + Rep If You Like my Scripts
  •  
    0 Thanked you For This Useful Post:
    uCause Community » Trash & Archives » Other » jQuery (Must Read)
    • Page 1 of 1
    • 1
    Search:


    "Making uCoz web designs simple and easy to use"
    - uCause Developers