Is there a way to retrieve the class name of an EventTarget
element in Angular 2 without using jQuery? Currently, I am accessing the target element like this:
<div class="orig-post" (mousemove)="onMouseMove($event)"></div>
onMouseMove(event: MouseEvent): void {
this.target = event.target
console.log(this.target) // Outputs the element the mouse is currently over
}
I want to store the class name of the target element in a variable. In pure Javascript, something like getSelection()
allows you to access the parent element's class name with
selection.anchorNode.parentElement.className
. How can I achieve the same result in Angular 2?