javascript - Can't change text in button -
here code book "html 5 + js dummies", looking @ more 2 hours , can't find reason why doesn't want work. i'm in stage , sorry newb question.
<!doctype html> <html> <head> <title> outputting data html </title> <script language ="javascript"> { document.getelementbyid("mytext"). innerhtml ="clicked!"; } </script> </head> <body> <h1> creating html element output </h1> <div> <p id="mytext">change me </p> </div> <div> <input id="btnclickme" type="button" value = "click me" onlick="writetext()"/> </div> </body> </html>
<!doctype html> <html> <head> <title> outputting data html </title> <script> function writetext() { document.getelementbyid("mytext"). innerhtml ="clicked!"; } </script> </head> <body> <h1> creating html element output </h1> <div> <p id="mytext">change me </p> </div> <div> <input id="btnclickme" type="button" value = "click me" onclick="writetext()"/> </div> </body> </html>
here's did/what wrong:
- you have used wrong syntax functions or forgot use function keyword
- you misspelled onclick (onlick)
i moved script part out of head
Comments
Post a Comment