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:

  1. you have used wrong syntax functions or forgot use function keyword
  2. you misspelled onclick (onlick)
  3. i moved script part out of head

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

Nuget pack csproj using nuspec -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -