Copy text without typing or buttons
P粉785522400
P粉785522400 2023-08-30 09:21:39
0
1
438

How do I create a function that copies text to the clipboard? I found on w3schools how to do it using an input box, but I don't know how to do it using just text (like Hypixel for example)

P粉785522400
P粉785522400

reply all (1)
P粉978742405

You don't need to use a library to accomplish this.
Just usedocument.execCommand("copy")

$("#txt").on("click", function (event) { var $temp = $(""); $("body").append($temp); $temp.val($("#txt").html()).select(); document.execCommand("copy"); $temp.remove(); });
 
复制这段文字
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!