JSFiddle - React, Tailwind, and code Playground

by Alejandro

HTML

<p>Scroll to the bottom...</p>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<a href="">Click Me - I won't refresh the page</a>

CSS

div {
    background-color: blue;
    width: 100%;
    height: 200px;
    margin-bottom: 3px;
}
.red {
    background-color: green;
}

JavaScript

$('a').on('click', function(e) {
    e.preventDefault();
    $('div').toggleClass('red');
})