Solution 1 :

You can write basic js technically, but with type of course.

changeId() {
  let element: HTMLElement = document.getElementById('id'); = newId;

or just

changeId() {
  document.getElementById('id').id = newId;

Problem :


<span id="IDs"> hello </span>


  // call IDs and change value


In TypeScript how do I change the content of id IDs that’s in my HTML inside my .TS?


Comment posted by How do I change the ID of a HTML element with JavaScript?

Does this answer your question?

Comment posted by Heretic Monkey

TypeScript is a superset of JavaScript. When searching for “how to do something” don’t limit yourself to “…in typescript”.

Comment posted by Heretic Monkey

You don’t need the

Comment posted by Natixco

Yes. And? I wrote it that way. If you don’t like it you can answer it in your way 😉