﻿$(document).ready(function(){

//-------------------Getting Started--------------------
   $("#helloWorld").click(function(event){
     alert("Hello World!");
   });
//--------------------------------------------------------------

//-------------------jQuery Chainability Demo--------------------
$("a").filter(".clickme").click(function(){ 
       return confirm("You are now leaving the site.");
     }).end()               
   .filter(".hideme").click(function(){
        $(this).hide();
        return false;
     }).end();              
//To achieve the above functionality using traditional javascript, you should loop through all anchor tags,find the 
//tags with the class name "clickme","hide" and add click event handlers, which is a cumbersome act.
//-------------------jQuery Chainability Demo-------------------

//-------------------jQuery Selectors--------------------
$("#btnEven").click(function(){
$("tr:even").toggleClass("redBG");
});

$("#btnOdd").click(function(){
$("tr:odd").toggleClass("blueBG");
});
//-------------------jQuery Selectors--------------------

//-------------------jQuery Core - Each --------------------
    $("#btnEach").click(function () {
        $("li").each(function(){
        $(this).toggleClass("red");
        });
    });
//-------------------jQuery Core - Each --------------------
 
 
 //-------------------jQuery Traversing --------------------
 $("p").find("span").css('color','red');
 //-------------------jQuery Traversing --------------------
 
  //-------------------Attributes--------------------
$("button:gt(1)").attr("disabled","disabled");

$("#btnAddClass").click(function(){
 $("p:last").addClass("highlight");
});

$("#btnRemoveClass").click(function(){
 $("p:last").removeClass("highlight");
});
 //-------------------Attributes--------------------
 
 //-------------------Manipulation--------------------
 $("#btnAppend").click(function(){
 $("#span2").appendTo("#span1");
 });
 //-------------------Manipulation--------------------

//-------------------Effects--------------------
 $("#btnToggle").click(function(){
     $("#block").slideToggle("slow");
 });
 //-------------------Effects--------------------

 //-------------------AJAX--------------------
 hideAnimation();
 $("#btnAjax").click(function(){
     $("#loading").show();
    $("#myAjaxDiv").load("../index.htm #jQuery li:first",hideAnimation);
 });
 
 function hideAnimation() {
    $("#loading").hide();   
    }
 //-------------------AJAX--------------------


//-------------------Code for obtaining equal div heights-------------------
$('.masterDiv').each(function(){
	$('.divLeft', this).height() > $('.divRight', this).height() ? $('.divRight', this).height($('.divLeft', this).height()) : $('.divLeft', this).height($('.divRight', this).height());
});
//-------------------Code for obtaining equal div heights-------------------
});

