Files
what-new-in-chrome/public/demo/modern-web-guidance/app.js
T

17 lines
536 B
JavaScript

const dialog = document.querySelector("#guided-dialog");
const openDialog = document.querySelector("#open-dialog");
const copyButton = document.querySelector("#copy");
const commands = document.querySelector("#commands");
openDialog.addEventListener("click", () => {
dialog.showModal();
});
copyButton.addEventListener("click", async () => {
await navigator.clipboard.writeText(commands.textContent.trim());
copyButton.textContent = "已复制";
setTimeout(() => {
copyButton.textContent = "复制命令";
}, 1200);
});