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);