About Lesson
Inline JavaScript:
Inline JavaScript is written directly inside the HTML elements using the onclick, onload, or similar event attributes. This method is not widely recommended because it mixes JavaScript code with HTML structure, making the code harder to maintain.
Example:
JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inline JavaScript Example</title>
</head>
<body>
<button onclick="alert('Hello from JavaScript!')">Click Me</button>
</body>
</html>
In this example, JavaScript is embedded directly within the onclick attribute of the <button> element.