全屏
<div class="instructions">
  (click here, then press <code>TAB</code>)
</div>
<button tabindex="-1" class="inactive">
  Can't reach me with the TAB key!
</button>
<button class="active">
  Click to focus() the previous element
</button>
body {
  font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;
  margin: 2em;
}

.instructions {
  margin: 8px;
}

button {
  display: inline-block;
  font-size: 16px;
  border: 2px solid black;
  border-radius: 8px;
  padding: 8px;
  margin: 8px;
}

button:focus {
  outline: 4px dashed darkorange;
}
const inactiveButton = document.querySelector(".inactive");
const activeButton = document.querySelector(".active");
activeButton.addEventListener("click", () => inactiveButton.focus());
返回