Advertisement
JoachimBrnd

Add a copy to clipboard field_code

Aug 15th, 2022
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <style>
  2. .parent{
  3.   display: flex;
  4.   position: relative;
  5.   font-size: 12px;
  6.   font-weight: bold;
  7. }
  8.  
  9.  
  10. .left{
  11.   border: 2px solid;
  12.   border-right:none;
  13.   border-radius:10px;
  14.   border-bottom-right-radius:0;
  15.   border-top-right-radius:0;
  16.   padding: 5px 10px;
  17.   overflow: hidden;
  18.   text-overflow: ellipsis;
  19. }
  20.  
  21.  
  22. .right{
  23.   border: 2px solid;
  24.   cursor:pointer;
  25.   border-radius:10px;
  26.   border-left:none;
  27.   border-bottom-left-radius:0;
  28.   border-top-left-radius:0;
  29.   padding: 5px 10px;
  30.   background-color: #FFA500;
  31. }
  32. </style>
  33. <script>
  34. document.addEventListener("DOMContentLoaded", function() {
  35.         const existCondition = setInterval(function() {
  36.             if ($('#copy-page').length) {
  37.                 const text = document.querySelector(".left");
  38.                 const button = document.querySelector(".right");
  39.                 function copyText() {
  40.                     navigator.clipboard.writeText(text.innerText).then((t) => {});
  41.                 }
  42.                 button.addEventListener("click", copyText);
  43.                 clearInterval(existCondition);
  44.             }
  45.         }, 100);
  46.     });
  47. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement