HTML
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link name="favicon" type="image/x-icon" href="https://skillzam.com/uploads/system/e353194f3b7cd1b75d69c3ab88041985.png" rel="shortcut icon" />
<title>Add inline JavaScript to HTML</title>
<!-- Button Styling CSS code-->
<style>
#btn {
background-color: #004AED;
color:white;
font-size: 1.2em;
border-color: blue;
border-radius: 3px;
padding: 10px 30px;
}
</style>
</head>
<body>
<h1>Demo: Add inline JavaScript to HTML</h1>
<!-- Inline JavaScript handlers - onclick="createPara()" -->
<button id="btn" onclick="createPara()">Click Me</button>
<!-- JavaScript code Starts here -->
<script>
function createPara() {
const para = document.createElement('p');
para.textContent = 'You just clicked the button!';
document.body.appendChild(para);
}
</script>
<!-- JavaScript code Ends here -->
</body>
</html>