From ae651900b2e739175640b033fa983d0cab1701ff Mon Sep 17 00:00:00 2001 From: "Glitch (glitch-hello-website)" Date: Thu, 27 May 2021 14:34:27 +0000 Subject: [PATCH] Exporting to glitchdotcom/glitch-hello-website ./script.js:31317407/1858 --- script.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/script.js b/script.js index f34fa59..787bf14 100644 --- a/script.js +++ b/script.js @@ -13,10 +13,12 @@ Make the "Click me!" button rotate when the visitor clicks it: */ const btn = document.querySelector("button"); // Get the button from the page // Detect clicks on the button -btn.onclick = function() { - // The JS works in conjunction with the 'rotated' code in style.css - btn.classList.toggle('rotated'); -}; +if (btn) { + btn.onclick = function() { + // The JS works in conjunction with the 'rotated' code in style.css + btn.classList.toggle("rotated"); + }; +} // This is a single line JS comment /*