Login To InderWeb ! Just Play !

Username:
Password:

UserSubmittedComments

What's jQuery how to use jquery

Jquery is lightweight Java Script Library that provides functionality for may events in just few lines of code.To use jquery you must download first the jquery library file.

 You can download the latest version -- 1.2.6 the latest version from jquery site.

Functionality And Working Of Jquery :-

jQuery's functionality and method is simple: find things, do action. We select elements from the document via the DOM using the jQuery function, aliased as $(). This handy function acts just like document.getElementById(), except that instead of only supporting IDs, it supports CSS selectors and some XPath selectors; and, instead of returning one element, it can return an array of elements. Okay, so maybe a better description of $() is that it's like document.getElementById() on steroids.

We then use functions to perform actions on our selections. For example, to append the text "Hello World!" to all divs with the class 'divContent', then set the color to red, we'd use the following code:

$("div.divContent").append("Hello World!").css("color","red");

Easy! Normally, this task would require two lines of code, like so:

$("div.divContent").append("Hello World!");
$("div.divContent").css("color","red");

For this example to work you will need to download jquery library also from jqury.com site.
========================SIMPLE JQUERY  AJAX data.html=============================
<html>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <title>AJAX using jQuery Example demo</title>          
    </head>
    <body>
        <div id="page" style="border:2px solid gray;width:200px;text-align:center;align:center">
        <script type="text/javascript">
        $(document).ready(function(){
            $("#getData").click(function(){
                $("#ajxData div").load("data.php");
            });
        });
        </script>
        <input type="submit" id="getData" value="Show data!"><br />
        <div id="ajxData"><div></div></div>
        </div>
    </body>
</html>
=======================================================================
//Code for data.php We can have SQl connections to get data from table
<?php
$data=array(
  " Jquery is lightweight Java Script Library that provides functionality for may events in just few lines of code.",

"jQuery's functionality and method is simple: find things, do action.",
"We then use functions to perform actions on our selections.");

echo $data[rand(0,count($data)-1)];
die();
?>

===================================Happy Code Playing :) ======================