jQuery addClass example

Change class name on click in jQuery

HTML

<div class="sn-stream-textarea-container">
   <span class="sn-stream-input-decorator" style="background-color: #badaff"></span>
   <textarea id="activity-stream-comments-textarea" class="sn-string-textarea form-control ng-pristine ng-untouched ng-valid ng-isolate-scope ng-empty ng-valid-required"></textarea>
</div>

JavaScript

const elements = document.querySelectorAll(".sn-stream-input-decorator")
for (const element of elements) {
 element.parentNode.style.backgroundColor = element.style.backgroundColor
 
 // Use either of these two
 element.nextElementSibling.style.backgroundColor = "blue"
 document.getElementById("activity-stream-comments-textarea").style.backgroundColor = "blue"
}