Why doesn’t my Javascript code work in a browser?

Ragu P October 21, 2014

I’ve been trying to code something in Javascript inside of Notebook ++ but when I open it in a web browser (Chrome or Internet Explorer), the function of the script doesn’t work.

For instance:

Change button/h1>

This will change button

Click Me!

This is a demonstration.

function myFunction() {
 document.getElementById("demo").innerHTML = "Hello JavaScript!";

You see everything but when I click on the icon for the button, it doesn’t work. What am I doing wrong?


  1. Ragu P
    October 22, 2014 at 8:10 pm

    the code I'm posting is being stripped for some reason. I had much more than in my response to the initial comment.

  2. Indo Traveller
    October 22, 2014 at 1:37 pm

    Seeing the code section will help us understand what you have written.

    But yiu should have a div whose id = demo

    And onclick =

    For it to work

    There are some similar clicks n buttons on a page where I post photos


  3. Matthew Hughes
    October 22, 2014 at 1:33 pm

    Obvious question, but are you actually calling the function? Also, is there anything in your console?

    I agree with Oron. We need a bit more context to help you.

  4. Ragu P
    October 22, 2014 at 1:04 pm

    Oron, there is a sample below of a short one. Thanks.


    Click me to display Date and Time.

  5. Oron J
    October 22, 2014 at 8:27 am

    Ragu, can you post the _entire_ code of a page (preferably a short one) so we can see it in context?