0

I am writing a NPM package and I want to write something to the DOM inside my function. But I get an error saying the document is not defined example,

foo package:

module.exports = {
    sayHello: function(){
        document.getElementByID('#hello').innerHTML('Hello');
    }
}

In client-side javascript:

import { sayHello } from 'foo';
$('#myButton').click(() => sayHello());
Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
Tanvir
  • 1
  • 2

1 Answers1

0

First of all there is a typo at

document.getElementByID

The correct spelling is

document.getElementById

Besides that the question may be a duplicate of this question

Rossi
  • 1
  • 2