0

Can you please tell me what am I doing wrong ? I have btn. I select this btn by id and I would like to massage it during processing. I am getting error. Object is possibly 'null'

 <button className='btn btn-primary rounded-0' id='loadBtn'>Upload Image</button>

in js, or in react I would do this way, but in typescript is red underline.

document.getElementById('loadBtn').textContent = 'Processing...'
erza
  • 107
  • 8
  • 2
    Maybe this will help? https://stackoverflow.com/q/52491832/535275 – Scott Hunter May 15 '23 at 18:32
  • This way is working for me: const btn = document.getElementById('loadBtn') as HTMLFormElement and then btn.textContent = 'Processing...' Is any other way how to do it? Thank you – erza May 15 '23 at 18:37

0 Answers0