Example JavaScript with jQuery

JQuery Click Event. Introduction to Javascript Language & Encoding

by ITpresent

HTML

<!DOCTYPE html>
<html>
 <head>
  <title>IT PRESENT</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
 </head>
 <body>
 <div align="center">
 
 </div>
   <h1>INDEX PAGE</h1>
   <p>text on html page</p>
   <br>
   <button>CLICK HERE</button>
   <br><br>
   <a href="https://itpresent.com/web/javascript/javascript.php">
     Introduction to Javascript Language
   </a>
 </body>
</html>

CSS

body {
background-color: yellow;
}
h1 {
font-size:45px;
}
.p {
color: red;
background-color: green;
}
.r {
background-color: blue;
font-size:45px;
}

JavaScript

$(document).ready(function(){
    $("button").click(function(){
         $("h1").addClass("p");    
         $("p").addClass("r");        
    });
});