Please review the code below:
$(".nwe-cl-icontext").click(function () {
$(this).parent().toggleClass("nwe-active");
})
.nwe-cl-c.nwe-active {
background: red;
}
.nwe-cl-c {
background: green;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="nwe-g-m">
<div class="nwe-cl-c nwe-active">
<div class="nwe-cl-icon-m is"></div>
<div class="nwe-cl-icontext">btn3</div>
</div>
<div class="nwe-cl-c">
<div class="nwe-cl-icon-m is"></div>
<div class="nwe-cl-icontext">btn2</div>
</div>
<div class="nwe-cl-c">
<div class="nwe-cl-icon-m is"></div>
<div class="nwe-cl-icontext">btn3</div>
</div>
</div>
Seeking assistance on achieving a specific functionality - when clicking the second button, the "nwe-class" should be added to the second parent element and so forth for subsequent buttons.