I have multiple elements in DOM with the same class name - 'ps__rail-y'. I want to iterateover those elements and listen to click event on individual element with the class and stop event propagation. I have tried the approach below, but somehow it is not working.
onClickScrollBar(){
let elements : Array<any> = this._elRef.nativeElement.querySelectorAll('.ps__rail-y');
elements.forEach((index : number) => {
let element = document.getElementsByClassName('ps__rail-y')[index] as HTMLElement;
element.addEventListener('click', (e : Event) => {
e.stopPropagation()
}, true)
})
}