Files
old.martials.no/src/utils/dom.ts

10 lines
314 B
TypeScript
Raw Normal View History

/**
* Get an element by id
* @param id The id of the element
* @type T The type of the HTMLElement
* @returns The element with the given id, or null if it doesn't exist
*/
export function getElementById<T extends HTMLElement = HTMLElement>(id: string): T | null {
2023-06-03 18:12:13 +02:00
return <T>document.getElementById(id);
}