1document.getElementById("myBtn").addEventListener("click", function() {
2 alert("Hello World!");
3});
1<!DOCTYPE html>
2<html>
3 <head>
4 <title>Title of the document</title>
5 </head>
6 <body>
7 <p>There is a hidden message for you. Click to see it.</p>
8 <button onclick="myFunction()">Click me!</button>
9 <p id="demo"></p>
10 <script>
11 function myFunction() {
12 document.getElementById("demo").innerHTML = "Hello Dear Visitor!</br> We are happy that you've chosen our website to learn programming languages. We're sure you'll become one of the best programmers in your country. Good luck to you!";
13 }
14 </script>
15 </body>
16</html>
1 document.getElementById("Save").onclick = function ()
2 {
3 alert("hello");
4 //validation code to see State field is mandatory.
5 }
1document.getElementById('button').onclick = function() {
2 alert("button was clicked");
3};
1 <input type="text" name="text" id="test" onmouseover="skriv('klick')">
2 <input type="button" name="send" value="Skicka" id="klick" onclick="skriv('test')">
3
4
5 <script src="lib/script.js"></script>
6
7
8// in lib/script.js
9
10 function skriv(name) {
11 document.getElementById(name).style.backgroundColor='red';
12 }