Inactive Tutor answered 04/11/21
Another way to do this and keep script in your head is by adding the attribute defer. For example, <Script defer ></script>. This will allow us to load our javascript after the html is loaded..
Janet M.
asked 03/20/21Hi,
I just started learning JavaScript and HTML. I'm trying to make a message appear in the span with ID "message" when a button is clicked two different ways, first using JavaScript and also using jQuery. However, neither is working for me. Here is the JavaScript:
And the jQuery version:
Can anyone tell me what I'm doing wrong? Thanks!!
Inactive Tutor answered 04/11/21
Another way to do this and keep script in your head is by adding the attribute defer. For example, <Script defer ></script>. This will allow us to load our javascript after the html is loaded..
Inactive Tutor answered 03/22/21
Hi Janet,
If you place your <scripts> tag in the <head> tag, the browser will read those before it reads the body's content. That means it cannot access both the <button> and the <span>. If you place your <scripts> inside the body section right before the closing tag </body>, it should work.
There is also a typo on this line below. It should be getElementById since Javascript is case sensitive.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.