23
Jan
10

1. What is $ in jQuery?

The $ represents the jQuery Function, and is actually a shorthand alias for jQuery. Prototype, jQuery, and most javascript libraries use the $ as the primary base object (or function). Most of them also have a way to relinquish the $ so that it can be used with another library that uses it. In that case you use “jQuery” instead of “$”. In fact, “$” is just a shortcut for “jQuery”. JavaScript allows upper and lower letters, numbers, and $ and _. The $ was intended to be used for machine-generated variables (such as $0001).

2. How to use?

You can load the jquery class from Google AJAX Libraries API.

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script>
	google.load("jquery", "1.4.0");
</script>

or
You can also download the jQuery libraries files from the jQuery site http://hinturl.com/jquerydownload to your application folder and include directly to the code.

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

3. Write your first jQuery program?

<html>
<head>
<script src="jquery/jquery.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
	$(document).ready(function(){
	   alert("Hello World From JQuery!!");
	 });
</script>
</body>
</html>

Here the $(document) is the jQuery function which passes the document as the “selector“. And the .ready() is the event for document object. Refer http://hinturl.com/jquery-doument-events for other events.

And the above code you can write in this way also.

<script type="text/javascript">
	jQuery(document).ready(function(){
	   alert("Hello World From JQuery!!");
	 });
</script>

$() is replaced with jQuery().

  • del.icio.us
  • Digg
  • Facebook
  • LinkedIn
  • Google Bookmarks
  • Twitter
  • MySpace
  • Mixx
  • Reddit
  • DZone
  • Sphinn
  • StumbleUpon
  • Blogplay
  • Diigo
  • Live
  • MSN Reporter
  • Technorati
  • NewsVine
  • Yahoo! Bookmarks
  • Netvibes
  • Design Float
  • Add to favorites
  • email
  • Yahoo! Buzz
  • Gwar
  • FriendFeed
  • Tumblr
  • Print
  • PDF
  • RSS
This entry was posted in jQuery and tagged , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>