0

I'm just trying to make a Chrome extension. It opens a popup when clicked and when I click a button the textContent (also tried with innerHTML) should change. But chrome simply gives me the error.

popup.html:

    <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="popup.js"></script>
    <title>Document</title>
  </head>
  <body>
    <button id="button">Button</button>
    <p id="pa">Change me</p>
  </body>
</html>

popup.js:

document.getElementById("button").addEventListener("click", hello());
function hello() {
  var text = document.getElementById("pa");
  text.textContent = "I'm a paragraph!";
}

What am I doing wrong?

Dragon
  • 1
  • 2

0 Answers0