Wie erstelle ich ein Zwischenablageskript für zwei Kopierschaltflächen?HTML

HTML-Programmierer
Anonymous
 Wie erstelle ich ein Zwischenablageskript für zwei Kopierschaltflächen?

Post by Anonymous »

Ich habe zwei Textabsätze, jeder hat eine Schaltfläche „In die Zwischenablage kopieren“ und jede Schaltfläche hat ihr eigenes Skript. Wie kann ich diese beiden Schaltflächenskripte zu einem kombinieren?
HTML:

Code: Select all

Copy to clipboard 1
Copy to clipboard 2


Copy to clipboard
Copy text



Copy to clipboard
Copy text


und JS:

Code: Select all

function myFunction() {
navigator.clipboard.writeText(document.querySelector("#text1").innerText);
var tooltip = document.getElementById("myBtn");
tooltip.innerHTML = "Copied";
}
function outFunc() {
var tooltip = document.getElementById("myBtn");
tooltip.innerHTML = "Copy to clipboard";
}


function myFunction_1() {
navigator.clipboard.writeText(document.querySelector("#text2").innerText);
var tooltip = document.getElementById("myBtn-1");
tooltip.innerHTML = "Copied";
}
function outFunc() {
var tooltip = document.getElementById("myBtn-1");
tooltip.innerHTML = "Copy to clipboard";
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post