我正在尝试在div
点击上获取附加到div
的类的名称:
<div class='hello new fun' id="clckBtn" (click)="fireMyEvent($event)">Click me</div>
fireMyEvent(event){
let elem = event.target;
console.log(elem.classList)
}
输出为["hello", "new", "fun", value: "hello new fun"]
有没有什么方法可以直接在点击时获得数组中类的名称,而不会分割 值