I've got a 3 items that are clickable and need to have the text changed on click.
the HTML
<div class="aaa">
<p class="bbb">Hello</p>
</div>
<div class="aaa">
<p class="bbb">Hello</p>
</div>
<div class="aaa">
<p class="bbb">Hello</p>
</div>
and the jQuery
$('.aaa').on("click", function() {
$('.bbb', this).text(function(_, oldText) {
return oldText === 'Hello' ? 'Goodbye' : 'Hello';
});
return false;
});
My problem is I need to 'reset' the text if I click a different item. What do I need for this?
Here's the work so far on CodePen - http://codepen.io/sturobson/pen/zbunG