Div Tag Actions Using JQuery

Div tag actions using JQuery. 
  1. <!DOCTYPE html>  
  2. <html>  
  3.   
  4. <head>  
  5.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>  
  6.     <script>  
  7.     // Function which is called on div click  
  8.     function MyFunction()  
  9.     {  
  10.         alert("Div Clicked");  
  11.     };  
  12.     $(document).ready(function()  
  13.     {  
  14.         // Adding text to Div tag  
  15.         $('#MyDiv').text('Add to Favorites Conformation');  
  16.         // Changing div color  
  17.         $('#MyDiv').css("background-color""yellow");  
  18.         // Adding Click event to div tag  
  19.         $("#MyDiv").attr("onclick"'MyFunction()');  
  20.         // Empty the Div content  
  21.         $('#divContainer').empty();  
  22.         // Adding html code to div   
  23.         $("#myEmptyDiv").html("<h2>Ramakrishna Basagalla</h2>");  
  24.     });  
  25.     </script>  
  26. </head>  
  27.   
  28. <body>  
  29.     <div id="MyDiv">MyDivTag</div>  
  30.     <div id="divContainer">My Default text</div>  
  31.     <div id="myEmptyDiv"></div>  
  32. </body>  
  33.   
  34. </html>