@todojs/

08.shadowRoot-activeElement

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>activeElement</title>
</head>
<body>
<div id="test"></div>
<script>
  const div        = document.querySelector ('#test');
  const shadowRoot = div.attachShadow ({mode : 'closed'});
  const check = document.createElement('button');
  check.innerHTML = 'check';
  check.addEventListener('click', function() {
    shadowRoot.activeElement.style.backgroundColor = 'red';
  });
  shadowRoot.appendChild(check);
</script>
</body>
</html>
result
console