Looking to work with an HTML tag and retrieve its attribute, here is my code snippet:
findPosition(target: HTMLDivElement): IPiece {
const row: number = parseInt((HTMLDivElement).parentElement.getAttribute('row'));
const column: number = parseInt((HTMLDivElement).parentElement.getAttribute('column'));
const position: IPosition = { row, column };
const pieceInstance = this.piecePlace[row][column];
return { position, instance: pieceInstance };
}
However, encountering the following issue with
parseInt((HTMLDivElement).parentElement.getAttribute('row'))
:
Property 'parentElement' does not exist on type '{ new (): HTMLDivElement; prototype: HTMLDivElement; }'.ts(2339)
Any suggestions on how to solve this?