jQuery addClass example

Change class name on click in jQuery

by davehol

HTML

<label for="male">Local students
  <input type="radio" id="male" name="gender" value="M">
   <span></span>
</label>


<label for="female">International students
  <input type="radio" id="female" name="gender" value="F">
   <span></span>
</label>
<div class="filterWrapper" >
<a class='Vocational' href='#'>Certificates and diplomas</a>
<a class='Undergraduate ' href='#'>Degrees</a>
<a class='showAll' href='#'>Show all</a>
</div>

CSS

.xm-grouped-table a:hover {
    color: rgb(58, 58, 58);
    opacity: 0.5;
    text-decoration: underline;
}

.rmit-table__wrapper {
  overflow-x: auto;
}

.Vocational, .Undergraduate, .showAll{
    font-family: Arial ;
    background-color: rgb(255, 255, 255);
    color: #333333;
    outline: none;
    border-bottom: 2px solid #E1E1E1;
    display: block;
    font-size: 16px;
    margin: 0;
    margin-bottom: -2px;
    white-space: pre-wrap;
    line-height: 16px;
    padding: 7px 16px 15px 16px;
  
    text-decoration: none !important;
    float: left;
    position: relative;

}
.Vocational:hover, .Undergraduate:hover, .showAll:hover{
    border-bottom: 2px solid #E60028;
    color: #000054;

}


.filterWrapper{
  
  width: 100%;
  border-bottom: 2px solid #E1E1E1; 
   float: left;
   height:20 px;
   margin-top :32px;


  
}

input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

label {
  position: relative;
  cursor: pointer;
  padding-left: 24px;
  display: inline-block;
  line-height: 1.2;
  margin-right: 36px;
  font-family:Arial;
  font-size:16px;
  font-weight:normal;
}

span {
  position: absolute;
  left: 0;
  top: 0;
  height: 16px;
  width: 16px;
  background: #FFF;
  border: 1px solid #6E6E6E;
  border-radius: 50%;
}

span:after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6E6E6E;
  display: none;
}

input[type="radio"]:checked~span:after {
  display: block;
  background-color: #000054;
}
input[type="radio"]:checked~span {
  display: block;
  border: 1px solid #000054;
}

input[type="radio"]:focus~span {
  outline: none;
}

JavaScript

// find elements
var banner = $("#banner-message")
var button = $("button")
//$('html').height(900);
alert($('html').height());
// handle click and add class
button.on("click", function(){
  banner.addClass("alt")
})