0
help me to find the error in my code...
<!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>What JavaScript can Do </h1> <p id="demo">JavaScript can change the html content. </p> <button type="button" onclick="document.getElementById('demo').innerHTML = 'hello i m javaScrip'">Click Me</button> </body> </html>
9 Respuestas
+ 4
You have to use the same quotation marks, so it should be: "hello i m JavaScrip"
+ 1
Replace button tag with this one :
<button type="button" onclick="document.getElementById('demo').innerHTML='hello i m javaScrip'">Click Me</button>
You missed 't' at documen and missed ' at innerHTML function string value
+ 1
Hi @sorath, don't change double quote, try to add single quote before it, you miss the single quote closing, or try this on, it worked:
<button type="button" onclick="document.getElementById('demo').innerHTML='hello i m javaScrip'">Click Me</button>
+ 1
It works well in my code playground. All you need to do is copy your whole line of coding and paste it on HTML section in code playground (but if there's coding in that section you must clear it first). Then click run. I think it didn't run because you paste it in JS section. This way doesn't work since your coding combines HTML and JavaScript together in a same page.
Hope that answers your question. ☺
0
I think it should be 'document.getElement'
0
@Three G I have changed the double quotes but still shows the error.
0
<button type="button" onclick="document.getElementById('demo').innerHTML='hello I\'m JavaScript\'s'">
- 2
boa tarde
- 3
I think you can write javasript in <head>
eg:<head>
<javascript>
onclick function(){
document.ElementById("demo").innerHTML="......"
}
</javascrip>
</head>