A string of practical Js code The hidden js code that automatically copies the content to the clipboard. After the page deploys the auto copy content code, the content will be automatically copied to the clipboard as long as the user clicks on the computer or mobile phone, and the promotion and sharing code will be copied secretly. The practical js code is very simple to use, and only needs to copy the code to the page Template , can be used with slight modifications.
<script src=" https://cdnjs.cat.net/ajax/libs/ jquery /3.3.1/jquery.min.js"></script> <script src=" https://cdnjs.cat.net/ajax/libs/clipboard.js/1.7.1/clipboard.min.js "></script> <script> $("body").onclick = copycode(); $("body").attr("id" ,"copy"); $("body"). attr ("data clipboard text", "content to be copied"); function copycode(){var clipboard = new Clipboard('#copy');clipboard.on('success', function (e){console.log("copy ok");}); clipboard.on('error', function (e){console.log("copy error");});} </script>
Disclaimer:
Website: Click Copy to share with friends!
All content resources shared by this website, if not noted, are original by Blueleaf. If you need to reprint, please indicate the source; Please contact us in case of infringement Contact handling 。 Please understand!