$("#e1").click(function() {
$("#descriptions div").removeClass("show");
$("#e1d").addClass("show");
});
$("#e2").click(function() {
$("#descriptions div").removeClass("show");
$("#e2d").addClass("show");
});
<div id="descriptions">
<div id="e1"></div>
<div id="e1d" class="description"></div>
<div id="e2"></div>
<div id="e2d" class="description"></div>
</div>
I'm trying to figure out a way to not to repeat the code and have jQuery automatically search and link the divs. So it'd be wonderful to link every id with the name e1~∞ to e1~∞d. Not sure how to implement the proper Object-Oriented methodology. Thank you for reading!