JSFiddle - React, Tailwind, and code Playground
HTML
<div class="image-cat-hover" cat-text="Category 1 text">
<p>Hover for cat 1</p>
</div>
<div class="image-cat-hover" cat-text="Category 2 text">
<p>Hover for cat 2</p>
</div>
<div class="image-cat-hover" cat-text="Category 3 text">
<p>Hover for cat 3</p>
</div>
<div class="default">
<p id="placeholder">Default Text</p>
</div>
CSS
* {
font-size: 20px;
text-align: center;
}
.image-cat-hover {
float: left;
width: 150px;
border: thin solid #CCC;
margin-bottom: 20px;
}
#cats, .default {
width: 450px;
}
JavaScript
$(document).ready(function() {
var defaultText = $(".default").text();
$(".image-cat-hover").mouseout(function() {
$(".default").text(defaultText);
}).mouseover(function() {
$(".default").text($(this).attr("cat-text"));
});
});