HEADER ADS 728X90

How to make Copy Clipboard Javascript Function || BY Ascode

copy to clipboard,copy to clipboard javascript,how to copy to clipboard in javascript,copy text to clipboard,how to copy to clipboard,copy text to clipboard javascript,javascript copy text to clipboard,javascript copy to clipboard,copy to clipboard javascript code,copy to clipboard using javascript,javascript copy to clipboard without input,copy to clipboard in js,copy to clipboard in react,copy to clipboard in javascript,copy text to clipboard using javascript,javascript tutorial,javascript tutorial for beginners,javascript,javascript tutorials,javascript for beginners,learn javascript,javascript course,java script tutorial,programming tutorial javascript,tutorial javascript,javascript basics,js tutorial,javascript tutorial in hindi,tutorial,javascript crash course,learn javascript for beginners,javascript tutorial beginners,javascript beginner tutorial,javascript tutorial game,javascript tutorial best,ascode, coding tutorial, how to learn coding easy way to learn coding

Hi dear welcome to Ascode Blog . In this post we are going to learn how to make copy clipboard javascript function onclick copy text. First Creat A index.html file Copy This HTML CODE and pest it one your code editor. 2ndly creat style.css file Then Copy The CSS CODE. 3rdly creat ap.js file Then Copy The Javascript CODE and pest it then open the index.html file with your browser.

HTML

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>copy clipboard js</title>
</head>
<body>
    <div class="container">
        <span id="Code" >ASCODE50</span>
        <span id="Btn" >COPY CODE</span>
    </div>
   

</body>
</style>
</html>

CSS

 body {
        display: flex;
        min-height: 100vh;
        justify-content: center;
        align-items: center;
        background: #111;
        font-family: sans-serif;
    }
    .container {
        display: flex;
        background: #fff;
        padding: 10px;
        border-radius: 4px;
    }
    #Code {
        padding: 5px;
        font-size: 2rem;
        font-weight: bold;
        letter-spacing: 1px;
        margin-right: 20px;
    }
    #Btn {
        padding: 5px;
        font-size: 2rem;
        font-weight: bold;
        letter-spacing: 1px;
        background: #090;
        color: #fff;
        border-radius: 4px;
    }

Javascript


    var Code = document.getElementById("Code");
    var Btn = document.getElementById("Btn");

    Btn.onclick = function(){
        navigator.clipboard.writeText(Code.innerHTML);
        Btn.innerHTML = "COPIED";
        setTimeout(function(){Btn.innerHTML = "COPY CODE";}, 1000)

    }

Youtube Tutorial

FLOW US ON SOCIAL MEDIA

Post a Comment

0 Comments

Join Telegram