I set a copy button in my code. The function is when user click copy button a random item from list will be copy. its works fine. But my problem is I want different item each click... ( not same as any previous item)
My random pic item code is
var myArray = ['name1', 'name2', 'name3','name4', 'name5', 'name6', 'name7', 'name8', 'name9', 'name10'];
function copyFunction() {
var rendtxt = myArray[~~(Math.random() * myArray.length)];
const textArea = document.createElement('textarea');
textArea.textContent = rendtxt;
document.body.append(textArea);
textArea.select();
document.execCommand("copy");
button.innerText = "Text copied";
textArea.remove();
}
document.getElementById('button').addEventListener('click', copyFunction);
You can check output here