Decoding the function programme

I am not able to execute the function when I click on the button.
Here is my code.


Click below to find my name.

Click here

Hello,My name is:

JS CODE:- function first(myname){ var elem=document.getElementById("hello"); elem.innerHTML=elem.innerHTML+myname; }

Well, make sure that java file is saved with same name as in html source. Also check ur HTML syntax and element ID. I have also attached solution for further clarification. Go through it.

Hello @keerbidare2001
First create my-javascript.js file

function myFunction(myName)
var elem = document.getElementById(“hello”)
elem.innerHTML = elem.innerHTML + myName;

than create webpage.html file

<!DOCTYPE html>
	<title>JavaScript Function</title>
	<script type="text/javascript" src="my-javascript.js"></script>
	<p id="para1">Click on the below to show my name.</p>
	<button onclick="myFunction('KEERTHANA');"> SHOW MY NAME </button>
	<p id= "hello">Hello Everyone, I am:</p> 

Open webpage.html file in browser.
Hope this information is useful for you :+1:

Thank you !
Your solution helped

Thank you!
This was of great help!