js on hover add class

by lemon kazi

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<div class='element-selector'>
 Test Text
</div>

CSS

.element-selector{
  color: red;
}

.blue{
  color: blue;
}

JavaScript

$('.element-selector').hover(function(){
	$(this).toggleClass('blue');
}, function(){
  $(this).toggleClass('blue');
})