<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv ...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script> </head> <body> <button type="button" class="btn btn_copy_text" data-clipboard-text="要複製的內容111111">1111111111111111</button> <button type="button" class="btn btn_copy_text" data-clipboard-text="要複製的內容222">2222222222222222</button> <button type="button" class="btn btn_copy_text" data-clipboard-text="要複製的內容333">33333333333333</button> <script> // 重要提示1 Clipboard 改成ClipboardJS 不然會提示錯誤的 綁定button上,避免ios的不相容性問題 console.log(ClipboardJS) //複製文本 var clip = new ClipboardJS('.btn_copy_text'); clip.on('success', function (e) { e.trigger.interHTML = "複製成功"; }); </script> </body> </html>