Source Code for " Click me " button:
<div id="mydiv"></div>
<button onclick="myfunction()">Click me</button>
<script type="text/javascript">
function myfunction()
{
document.getElementById('mydiv').innerHTML = 'I am the content, loaded by button onclick.';
}
</script>
The function with name " myfunction() " loaded when button will click. We have called the " myfunction() " on-click.
document.getElementById('mydiv').innerHTML="I am the content, loaded by button onclick.";
We have a div with id=''mydiv'' , in JavaScript code, we have wrote the code that mydiv will load with desired content "I am the content, loaded by button onclick" .
Lets continue the JavaScript in the next chapter .