-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage_Toggle.html
More file actions
42 lines (38 loc) · 1.36 KB
/
Image_Toggle.html
File metadata and controls
42 lines (38 loc) · 1.36 KB
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
<html>
<head>
<title>Image Toggle</title>
</head>
<body>
<h1 align ="center">TOGGLE</h1>
<img src="messi.jpg" width="500" height="500" id="messi" style = "display:block;margin:auto;"/>
<div>
<input type="button" onclick="imgToggler.toggle()" value="Toggle" style = "display:block;margin:auto;" />
</div>
<script>
var imgToggler = {}
imgToggler.toggle = function()
{
var imgEl = document.getElementById("messi")
var cursrc = imgEl.getAttribute("src")
if(cursrc == "messi.jpg")
{
imgEl.setAttribute("src","Screenshot (6).png")
}
else
{
imgEl.setAttribute("src","messi.jpg")
}
}
//var i = 0
/*function fun1(){
var el = document.getElementById('messi');
if(i%2 == 0)
el.setAttribute("src","Screenshot (6).png")
else {
el.setAttribute("src","messi.jpg")
}
i+=1;
}*/
</script>
</body>
</html>