I want to copy a card number into the clipboard so that I can paste it in Notepad. The code which I got from the internet works very well if tried in the developer toolbar o
Well, what are you copying? document.execCommand("copy");
requires something to be selected(highlighted) in the first place.
I think in your example, select
follows .val(). But in order for this to work you need to be selecting an element, not it's value.
$temp.val(data.CardNumber);
$temp.select();
copied = document.execCommand("copy");
$temp.remove();
if(copied){
alert('copied successfully');
}else{
alert('something went wrong');
}