-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.html
55 lines (46 loc) · 1.54 KB
/
modal.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
52
53
<!DOCTYPE html>
<html>
<head>
<style>
#Modal
{
display: none;
padding: 40px 40px 40px 40px;
background-color: white;
}
</style>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Page Title</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>
<button onclick="showmodal()" id="showmodalbtn">Show Modal</button>
<div id="Modal">
<button style="float: right;" id="Close" >Close</button>
<div class="modal-content">
</div>
</div>
<script>
function showmodal()
{
document.body.style.backgroundColor='gray';
var modal= document.getElementById('Modal')
document.getElementById('Modal').style.display='block';
var newpara=document.createElement('p')
modal.appendChild(newpara)
newpara.setAttribute("id","mypara")
document.getElementById("mypara").innerHTML+="this is a para added on modal by using js"
document.getElementById('showmodalbtn').style.display='none'
}
document.getElementById('Close').addEventListener('click',
function close()
{
document.getElementById('Modal').style.display='none';
document.body.style.backgroundColor='white';
document.getElementById('showmodalbtn').style.display='block'
}
)
</script>
</body>
</html>