jQuery addClass example

Change class name on click in jQuery

by Andy Bat

HTML

<div id="wrap-list">

<div class="wrap-row">
<div class="content">
<span class="sorter"><a herf=#></a> </span>
<span class="content-item">ewqewqeqwew fds sdf sd </span>
<span class="sorter"><a herf=#></a> </span>
</div>
</div>

<div class="wrap-row">
<div class="content">
<span class="sorter"><a herf=#></a> </span>
<span class="content-item">ewqewqeqwew fds sdf sd </span>
<span class="sorter"><a herf=#></a> </span>
</div>
</div>


</div>

CSS

body {
  background: #20262E;
  font-family: Helvetica;
}

#wrap-list{
  width:300px;
  overflow:auto;
  background-color:silver;
  height:200px;
}

.wrap-row{
  width:95%;
  height:40px;
  padding:5px;
}
.sorter{
  width:20px;
  float:left;
  background-color:blue;
  height:40px;
}
.content {
  width:200px;
  background-color:#777;
  position:relative;
  left:50px;
  float:left;
  height:40px
}

.content-item{
  width:160px;
  float:left;
  height:40px
 }

JavaScript

// handle click and add class
button.on("click", function(){
  banner.addClass("alt")
})