Help ... BUTTON is not working HTML/JS




If i click on button it should change to JS program … But BUTTON is not working … some were i did a stupid mistake

Can you post your actual code instead of screen shots? If you have a Codepen or JSFiddle of your project, that would be even better.

To enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


make sure you included the correct file. You sure that jss.js contains function test? Also make sure the js file is next to the html file.

This is also better to move the script tag inside the head tag, rather body

Your code should work as long as you have the jss.js file in the same directory as your html file.

Are you seeing any error messages in your browser’s console (Ctrl+Shft+J in Chrome)?

Yes I got an error in Chrome as ::
Uncaught ReferenceError: test is not defined at HTMLButtonElement.onclick …

That probably means the file you are specifying in your src is not in the same folder as your html file or you named the function something else in the .js file.

I created 2 different progs … js.html and jss.js … so now the 2 progs must be in same directory … ok …
Now I understood actual JS programming … TQ so much … I will try to solve it …

They are files and not programs (progs).

Hoo ok … learning … tq