copy text to clipboard jquery

function copyToClipboard(text) {
  var $temp = $("<input>");
  $("body").append($temp);
  $temp.val(text).select();
  document.execCommand("copy");
  $temp.remove();
}

$("#copyButton").on("click", function() {
  var textToCopy = $("#textToCopy").text();
  copyToClipboard(textToCopy);
});

Replace #copyButton with the ID of your copy button, and #textToCopy with the ID of the element containing the text to be copied.

Note: This code snippet uses jQuery for DOM manipulation.