-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreateElem.html
More file actions
41 lines (35 loc) · 1.24 KB
/
createElem.html
File metadata and controls
41 lines (35 loc) · 1.24 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<style>
.alert {
padding: 15px;
border: 1px solid #d6e9c6;
border-radius: 4px;
color: #3c763d;
background-color: #dff0d8;
}
</style>
<script>
let div = document.createElement('div')
div.className = "alert"
div.innerHTML = "<strong>Всем привет!</strong> Вы прочитали важное сообщение"
document.body.append(div)
let div2 = div.cloneNode(true)
div2.querySelector('strong').innerHTML = 'Всем пока!'
// document.body.insertAdjacentHTML("afterbegin", `<div id ="div" class="alert">
// <strong>Всем привет!</strong> Вы прочитали важное сообщение.
// </div>`);
setTimeout(() => {
div.remove();
document.body.append('Сообщение удалено через 3 сек');
document.body.append(div2) }, 3000)
</script>
</body>
</html>