// How javascript works with HTMl
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript Demo</title>
</head>
<body>
<h1 id="demo">Hello, JavaScript!</h1>
<button onclick="changeText()">Click me</button>
<script>
// JavaScript code starts here
// Function to change the text content of the heading
function changeText() {
var heading = document.getElementById("demo");
heading.textContent = "Text changed by JavaScript!";
}
// JavaScript code ends here
</script>
</body>
</html>
Check the detailed explanation and Output below





Leave a Reply