We can also pass the values from html code to java script easily. To show this we have created an example Html page which will pass the value to the java script function and this value will be shown with the java script's alert() method.
In this example we have made a java script function hello() which will display the name which has been passed from the HTML page. We have created a button and it calls the hello() function defined in java script with the argument. When we pass the argument to this method hello() in our example html page it pass it to the java script of the page and there we can display or use it.
Here is the full example code of PassHTML.html page as follows:
Get Hello Message<br>
<input type="button" onclick='hello("Rose India");' value="Click"/>
Output of the above example is as follows:
Recommend the tutorial