-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlab2.html
51 lines (42 loc) · 1.59 KB
/
lab2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph changed";
}
</script>
</head>
<body>
<h2>My first web page</h2>
<p>My first paragraph</p>
<p id="memo"></p>
<script>
document.getElementById("memo").innerHTML=5+6;
<script>
<h2> External JS</h2>
<p id="demo"> A para </p>
<button type = "button" onclick="myFunction()">Try it</button>
<p>(myFunction is stored in an external file called "myscript.js")</p>
<script src="myscript.js"></script>
<h1> A web page </h1>
<p id="demo"> A paragraph</p>
<button type = "button" onclick="myFunction()">Try it</button>
<h4> My First JS </h4>
<p id="para"> This is the first paragraph </p>
<button type="button"onclick='document.getElementById("para").innerHTML=Date()'>
Click This </button>
<p> In this case JS changes the value of the source attribute of an image </p>
<img id="myImage" src="dog.gif" style="width:400px">
<button onclick = "document.getElementById('myImage').src='dog.gif'">Dog</button>
<button onclick = "document.getElementById('myImage').src='cat.gif'">Cat</button>
<h2>Change Style</h2>
<p id="demo">JS can change the style of an HTML element</p>
<button type="button" onclick="document.getElementById('demo').style.fontSize='35px'">Click Me!</button>
<h2> What can JS do? </h2>
<p id="demo"> JS can hide HTML elements </p>
<button type="button" onclick="document.getElementById('demo').style.display='none'">NONE!</button>
<p id="demo"> JS can hide HTML elements </p>
<button type="button" onclick="document.getElementById('demo').style.display='none/block'">BLOCK!</button>
</body>
</html>