www.webdeveloper.com
Results 1 to 2 of 2

Thread: Please tell me the error in this code

Hybrid View

  1. #1
    Join Date
    Mar 2014
    Posts
    1

    Please tell me the error in this code

    I am new to coding and would like to know why the bolded innerhtml will not change onclick of button


    <!DOCTYPE html>
    <html>
    <head>
    </head>
    <body>
    <p align="right" id="cheese"></p>
    <button type="button" onclick="myfuncttion()" style="float:right">Transportation</button>
    <p align="right" id="m"></p>
    <script>
    var transportation="Car";
    document.getElementById("cheese").innerHTML=transportation;
    </script>
    <script>
    function myfunction()
    {
    document.getElementById("m").innerHTML"G";
    }

    </script
    </body>
    </html>

  2. #2
    Join Date
    Oct 2013
    Posts
    472
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>untitled</title>
    </head>
    <body>
    <p align="right" id="cheese"></p>
    <button type="button" onclick="myfunction()" style="float:right">Transportation</button>
    <p align="right" id="m"></p>
    <script>
    var transportation="Car";
    document.getElementById("cheese").innerHTML=transportation;
    </script>
    <script>
    function myfunction()
    {
    document.getElementById("m").innerHTML = "G";
    }
    </script>
    </body>
    </html>
    Last edited by Kevin2; 03-16-2014 at 05:28 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles