+ 3

Help my code not work

<button onclick="btn()"> read more </button> <p id="a"> </p> <style> function btn() { document.getElementById("a").innerHTML = "hi"; } </style> Error: btn() not defined This is made by in my mind, not by someone

24th Mar 2022, 3:59 AM
Zairy Putra
3 Answers
+ 5
Just replace 'style' tag with 'script' tag. "style" tag is for CSS "script" tag is for JS
24th Mar 2022, 4:11 AM
Arnav Gumber
Arnav Gumber - avatar
+ 4
Replace "style" with "script". You have created your Javascript function inside embedded style block.
24th Mar 2022, 4:10 AM
Ipang
+ 4
WOW, I always do this simplest mistake, sorry guys!, And thanks!
24th Mar 2022, 4:11 AM
Zairy Putra