JQuery : Introduction

JQuery is a lightweight JavaScript framework developed by John Resig. JQuery is a lightweight “write less, do more” JavaScript library.

The jQuery library contains the following features:

  • HTML element selections
  • HTML element manipulation
  • CSS manipulation
  • HTML event functions
  • JavaScript Effects and animations
  • HTML DOM traversal and modification
  • AJAX
  • Utilities

Adding the jQuery Library to Your Pages

The jQuery library is stored as a single JavaScript file ( u can get a copy of it from the JQuery site), containing all the jQuery methods. It can be added to a web page with the following mark-up:

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

You can use the alternate version of the JQuery by referring to the site..

<script type="text/javascript" src="="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

To start using JQuery,

<script type="text/javascript">
   $(document).ready(function(){
         //Your JQuery code
  }};
</script>

The JQuery loads the functions after only when all the DOM elements get loaded. Smile

jQuery Syntax

The jQuery syntax is tailor made for selecting HTML elements and perform some action on the element(s).

Basic syntax is: $(selector).action()

  • A dollar sign to define jQuery
  • A (selector) to “query (or find)” HTML elements
  • A jQuery action() to be performed on the element(s)

Examples:

$(this).hide() – hides current element

$(“p”).hide() – hides all paragraphs

$(“p.test”).hide() – hides all paragraphs with class=”test”

$(“#test”).hide() – hides the element with id=”test”

SHARE JQuery : Introduction

You may also like...

Leave a Reply

Your email address will not be published.

Share