Hello World Using JQuery Selector

In This Example we will Show you how to Display a alert when a link is clicked

Hello World Alert Using JQuery                                           
<html>                                                           
 <head>

 <title>Hello World Alert Using JQuery</title>

 <script type="text/javascript" src="jquery-1.2.6.min.js"></script>  

 <script type="text/javascript">

 $(document).ready(function(){

 $("a").click(function()

 {

 alert("Hello world! you have called me");

 });

});                             
 </script>                                                              
 </head>                                                                
 <body>   
 <a href=””>Click Me for Saying Hello</a>

  </body>                                                                
 </html>


Explanation:
 Code Part1 :
 The Above piece of code tells the browser to load the JQuery library which is located in the Folder you have created
 Code Part 2:
 $(document).ready(function(){
 $("a").click(function()
 {
 alert("Hello world! you have called me");
 });
});
---Here We register a ready event for the document ie we will perform the things whenever the DOM(document object model ) is Ready.
---$() is a JQuery Object
---$(“a”) is jQuery selector tool or method, which selects all “a”  elements
---The click() function we call next is a method of the jQuery object.

No comments:

Post a Comment

Please Provide your feedback here