<div id="content"></div>
<button class="btn btn-info" id="copy">copy</button>
<button class="btn btn-info" id="read">read</button>
const copy=document.querySelector("#copy")
copy.addEventListener("click", function(){
 navigator.clipboard.writeText("hello");
})

const read=document.querySelector("#read")
read.addEventListener('click', function(){
  navigator.clipboard.readText().then(text => {
      alert(text); // 剪貼簿中的文本內容
    });
})
// $("#read").click(function(){
  
// })

External CSS

  1. https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js