Going through HTML tutorials and stumbled on a difficulty with JavaScript. in JavaScript Posted October 14, 2022 I am trying to make a button that says "Click Me", that when clicked, changes the text above it from "Hi" to I'm Clicked!". Here is the source: ---------------------------------------------------------------------------------------------------------------------- <!DOCTYPE html> <html> <body> <p id="demo">Hi.</p> <script> function myFunction() { document.getElementByID("demo").innerHTML = "I'm Clicked!"; } </script> <button type="button" onclick="myFunction()">Click Me!</button> </body> </body> </html> ------------------------------------------------------------------- What am I doing wrong?
Going through HTML tutorials and stumbled on a difficulty with JavaScript.
in JavaScript
Posted
I am trying to make a button that says "Click Me", that when clicked, changes the text above it from "Hi" to I'm Clicked!".
Here is the source:
----------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<body>
<p id="demo">Hi.</p>
<script>
function myFunction()
{
document.getElementByID("demo").innerHTML = "I'm Clicked!";
}
</script>
<button type="button" onclick="myFunction()">Click Me!</button>
</body>
</body>
</html>
-------------------------------------------------------------------
What am I doing wrong?