From 988a88e19659756180dd0f5b0f6f8e8ae51c4ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=9F=E6=97=A5=E8=AF=AD?= Date: Fri, 26 Apr 2024 01:41:53 +0800 Subject: [PATCH] [fix] copy failure (#446) --- source/js/plugins/copycode.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/js/plugins/copycode.js b/source/js/plugins/copycode.js index 85f7c05..3f3f62a 100644 --- a/source/js/plugins/copycode.js +++ b/source/js/plugins/copycode.js @@ -7,7 +7,7 @@ window.codeElements.forEach((codeElement) => { // 添加点击事件监听 codeCopyBtn.addEventListener('click', async () => { - const codeToCopy = codeElement.querySelector('code')?.textContent || ''; + const codeToCopy = codeElement.querySelector('pre')?.innerText || ''; if (navigator.clipboard) { try { await navigator.clipboard.writeText(codeToCopy);