我想知道如何在typescript中的特定元素上绑定/触发鼠标悬停事件。这里的元素将基于键盘导航动态显示。
例如, 如果按下向下箭头键,我应该能够激活一行 ngx数据表。
@HostListener('document:keyup', ['$event'])
handleKeyboardEvent(event: KeyboardEvent) {
this.keyCode = event.keyCode;
let datatableRow = document.getElementsByClassName("datatable-row-wrapper");
//Check for Escape key navigation
if (this.keyCode === 27) {
// this._rows = [];
this.searchInputValue = null;
}
//Check for Up arrow navigation
if (this.keyCode === 38) {
alert("Im Up key!");
console.log(datatableRow);
if (datatableRow.length !== 0) {
console.log("datatable component", this.datatableComponent);
console.log("Child node", datatableRow[0].childNodes[6]);
}
}}