랜덤20자리숫자
by YH Park
HTML
<h1>20자리 랜덤 숫자 생성기</h1>
<button onclick="gen()">이 버튼을 눌러서 새로운 숫자 생성!</button>
<br><br>
<input id="target" style="font-size: 1.5rem" type="text" disabled="disabled">
<button onclick="copy()">클립보드로 복사</button>
JavaScript
function gen() {
var str = '';
str += Math.floor(Math.random() * 1e10);
str += Math.floor(Math.random() * 1e10);
document.getElementById('target').value = str;
}
function copy() {
var value = document.getElementById('target').value
var t = document.createElement("textarea");
document.body.appendChild(t);
t.value = value;
t.select();
document.execCommand('copy');
document.body.removeChild(t);
alert('[ '+value+' ] 복사완료\nctrl + v 로 원하는 곳에 붙여넣어 주세요.');
}
gen();