How to change HTML contents through JavaScript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to change HTML contents through JavaScript

I am trying to display contents to html through JavaScript but I keep getting error messages Please check the code below and tell me where I went wrong https://code.sololearn.com/WBQG15I6Filf/?ref=app

14th May 2020, 4:33 PM
Mehzie
Mehzie - avatar
3 Answers
+ 2
This error actually happens alot. Your code is correct, but you have to include this in the Javascript tab: window.onload = function() { //place your code here } This is needed because otherwise, the Javascript code will run before the HTML, and an error will be returned since "amount" doesn't exist yet.
14th May 2020, 4:38 PM
Jianmin Chen
Jianmin Chen - avatar
+ 1
Jianmin Chen thanks, that worked perfectly fine 😁
14th May 2020, 8:34 PM
Mehzie
Mehzie - avatar
0
You use. Css to change content and JavaScript for motions and interaction
23rd Nov 2020, 12:44 PM
Blesinto