jQuery addClass example

Change class name on click in jQuery

by cwhong

HTML

<!DOCTYPE html>
<title> First Submission </title>
<h1></h1>
<p class="Welcome"> welcome to kloe's page
</p>

<div class="topnav">
  <a class="active" href="#home">Home</a>
  <a href="food.html">Desserts around NYC</a>
  <a href="contact.html">About</a>
</div>

CSS

body {
  /* This sets the background with an image */
 background-image: url('https://i.imgur.com/eupvfFn.png');
 background-size: cover;
}

.Welcome {
  height: 100%;
  width: 100%;
  display: flex;
  position: fixed;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: 'Helvetica', sans-serif;
  font-weight: 300;
  font-size: 24pt;
  }
 
  /* Add a black background color to the top navigation */
.topnav {
  background-color: #eea7c2;
  overflow: hidden;
}

/* Style the links inside the navigation bar */
.topnav a {
  float: left;
  color: #f2f2f2;
  text-align: center;
  padding: 12px 14px;
  text-decoration: none;
  font-size: 14px;
}

/* Change the color of links on hover */
.topnav a:hover {
  background-color: #f3e06e;
  color: black;
}

/* Add a color to the active/current link */
.topnav a.active {
  background-color: #f5cada;
  color: white;
}