JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="titleToCopy" value="" />&nbsp;&nbsp;&nbsp;
<input type="button" value="Copy" onclick="copyTitleOnClipboard()"/>&nbsp;&nbsp;&nbsp;
<input type="button" value="Click Me to Exec Things" onclick="execThings()"/><br /><br />
<input type="text" style="width:200px;" id="coipedText" /><br />

JavaScript

$(document).ready(function(){
    setTimeout(function(){ execThings(); }, 5000);
});



function execThings() //This execute some operations and also calls other functions
{
    console.log(arguments.callee.name);
    //someDummy();
    copyTitleOnClipboard();
    //stopOriginalPlayer();
}


function copyTitleOnClipboard() // This function select and copies to the Operative System clipboard the content of the related text input
{
    console.log(arguments.callee.name);
    var titleInput = document.getElementById("titleToCopy");
    titleInput.focus(); // The function works good with or without this line
    titleInput.select();

    var r = document.execCommand("copy");
    r = r === true ? "has been" : "not";

    console.log("Title " + r + " copied to clipboard");
    var dest = document.getElementById("coipedText");
    dest.value = "Title " + r + " copied to clipboard";
    
}