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
| <!DOCTYPE html>
<html>
<head>
<title>Shadow DOM</title>
<style>
button {
font: 18px Century Schoolbook;
border: thin solid gray;
background: rgba(200, 200, 200, 0.5);
padding: 10px;
}
</style>
</head>
<body>
<h1>Shadow DOM</h1>
<button id='button'>Click this button</button>
<script>
var b = document.getElementById('button');
b.onclick = function (e) {
var sr= b.webkitCreateShadowRoot();
sr.innerHTML= '<p>This content is in the shadow DOM</p>' +
'<img src="beach.png">';
};
</script>
</body>
</html>
|