Professional Documents
Culture Documents
Java Script
Java Script
Java Script
Variables -
Key word let
Let counter = 0
Loops in javascript
While(true)
{
}
function greet()
{
Greeting function in javascript -
function greet()
{
alert('hello,
world');
}
<!DOCTYPE html>
<html lang="en">
<head>
<script>
document.addEventListener('DOM
ContentLoaded', function(){
document.querySelector('form')
.addEventListener('submit',
function() {
let name =
document.querySelector('#name'
).value;
event.preventDefault()
});
});
</script>
<title>
hello, title
</title>
});
});
</script>
<title>
hello, title
</title>
</head>
<body>
<form
onsubmit="greet(); return
false">
<input
autocomplete="off" autofocus
id="name" placeholder="name"
type="text">
<button
type="submit">Greet</button>
</form>
</body>
</html>
PLACING JAVASCRIPT IN A
SEPARATE FILE
-
<script>
src="hello.js"</script>