随机码生成小标签
javascript:(function() {
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
const length = 4;
let code = '';
for (let i = 0; i < length; i++) {
code += characters.charAt(Math.floor(Math.random() * characters.length));
}
const el = document.createElement('textarea');
el.value = code;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
alert('已将随机码复制到剪贴板中:' + code);
})();
生成一个长度为 4 的随机字符串,添加到剪贴板。