简体   繁体   中英

How to use Document Object Model in TypeScript?

I'm extremely new to typescript (and JavaScript for that matter), I think I've mastered the fundamentals when it comes to TypeScript (variables, arrays, if/else statements etc) but I would like to add functionality to my static webpages and I can't keep using console logs obviously. My experience with JavaScript is quite limited but for JavaScript I could do something like

"GetElementbyId", and manipulate it in JS, but in TypeScript there does not seem to be an equalivant(I'm probably wrong though...)

I tried finding tutorials for TypeScript Manipulation with DOM, but I could not find any. Is there a way to manipulate HTML elements with TypeScript and if so, how would I go about doing it?

Manipulating the DOM with TS is extremely similar to JS. Here is a link to a documentation page: https://www.staging-typescript.org/docs/handbook/dom-manipulation.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM