I want to make an <input> text box where you write a certain color, say 'red' and a certain text gets colored like that. I found some guidelines on how to do it, but the code is in JavaScript, instead of TypeScript. So far I got this:
HTML
<input id="color" />
<h1>Change the color</h1>
CSS
<style>
h1 {
color: var(--color, blue)
}
</style>
JavaScript
const color = document.querySelector('#color');
color.addEventListener('input', e => {
document.documentElement.style.setProperty('--color', color.value)
})
As I am using .ts classes, I am wondering how can the JavaScript above be written instead?
