I am trying to show an element if the user has something copied into the clipboard. I don't need to know the value, but if I can then it would be amazing.
The closest code I found to achieve this is this one below, but it's not working as the value is always empty and not printed in my console.log. Here below the sample:
function myTimer() {
console.log('Ciao!');
var tempElement = document.createElement("input");
tempElement.style.cssText = "width:0!important;padding:0!important;border:0!important;margin:0!important;outline:none!important;boxShadow:none!important;";
document.body.appendChild(tempElement);
var jTempEl = $(tempElement);
jTempEl.val(' ');
jTempEl.select();
jTempEl.trigger('paste');
var text = jTempEl.val();
console.log('tempElement text', text);
console.log('tempElement jTempEl', jTempEl);
document.body.removeChild(tempElement);
}
var myVar = setInterval(myTimer, 5000);
Do you have any idea why the variable text is empty? I copied something so the clipboard is not empty...
Thanks in advance.