HTML Javascipt
Javascipt
Javascript is a piece of code that executes in an HTML Page. We use JS for many purposes like showing an alert on a web page or performing some action on the button Click
We can use JS in HTML in 2 ways
1. External Javascript - Code is written in a Javascript file2. Internal Javascript - Code is written in HTML File under script tag
A External JS Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src = "/script.js" type = "text/javascript"/></script>
</head>
<body>
<input type = "button" onclick = "Hello1();" name = "ok" value = "Click Me" />
</body>
</html>
<html>
<head>
<title>Page Title</title>
<script src = "/script.js" type = "text/javascript"/></script>
</head>
<body>
<input type = "button" onclick = "Hello1();" name = "ok" value = "Click Me" />
</body>
</html>
A Internal JS Example
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script type = "text/JavaScript">
function Hello() {
alert("Hello, World");
}
</script>
</head>
<body>
<input type = "button" onclick = "Hello1();" name = "ok" value = "Click Me" />
</body>
</html>
<html>
<head>
<title>Page Title</title>
<script type = "text/JavaScript">
function Hello() {
alert("Hello, World");
}
</script>
</head>
<body>
<input type = "button" onclick = "Hello1();" name = "ok" value = "Click Me" />
</body>
</html>