let u = document.querySelector('.u-p');
for (let i = 0; i < u.length; i++) {
this[i].onclick = function() {
u.style.color = 'red';
}
}
<p class="u-p">11</p>
<p class="u-p">22</p>
<p class="u-p">33</p>
<p class="u-p">44</p>
let u = document.querySelector('.u-p');
let u = document.querySelectorAll('.u-p');
this[i].onclick = function() {
u[i].onclick = function() {
u.style.color = 'red';
u[i].style.color = 'red';
let u = document.querySelectorAll('.u-p');
for (let i = 0; i < u.length; i++) {
u[i].onclick = function() {
u[i].style.color = 'red';
}
}